Browse Source

Fixed contact form

development
LinguaFrancaTranslator 8 years ago
parent
commit
f917c20581
  1. 9
      app/helpers/application_helper.rb
  2. 2
      app/views/application/_contact.html.haml
  3. 10
      db/schema.rb

9
app/helpers/application_helper.rb

@ -217,15 +217,18 @@ module ApplicationHelper
end end
def url_for_locale(locale, url = nil) def url_for_locale(locale, url = nil)
return url unless locale.present?
unless url.present? unless url.present?
new_params = params.merge({action: (params[:_original_action] || params[:action])}) new_params = params.merge({action: (params[:_original_action] || params[:action])})
new_params.delete(:_original_action) new_params.delete(:_original_action)
if Rails.env.development? || Rails.env.test? if Rails.env.development? || Rails.env.test?
url = url_for(new_params.merge({lang: locale.to_s})) return url_for(new_params.merge({lang: locale.to_s}))
else
url = url_for(new_params)
end end
subdomain = Rails.env.preview? ? "preview-#{locale.to_s}" : locale.to_s
return url_for(new_params.merge(host: "#{subdomain}.bikebike.org"))
end end
return url if Rails.env.development? || Rails.env.test? return url if Rails.env.development? || Rails.env.test?

2
app/views/application/_contact.html.haml

@ -1,6 +1,6 @@
- contact_reason ||= nil - contact_reason ||= nil
- locale ||= nil - locale ||= nil
= form_tag (locale.present? ? contact_send_url : url_for_locale(locale, contact_send_url)), class: 'contact-form' do = form_tag (locale.present? ? contact_send_url : url_for_locale(locale, contact_send_path)), class: 'contact-form' do
= emailfield :email, nil, big: true, required: true unless logged_in? = emailfield :email, nil, big: true, required: true unless logged_in?
- if contact_reason.present? - if contact_reason.present?
= hidden_field_tag :reason, contact_reason = hidden_field_tag :reason, contact_reason

10
db/schema.rb

@ -286,11 +286,11 @@ ActiveRecord::Schema.define(version: 20160708042511) do
add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree
create_table "translation_records", force: :cascade do |t| create_table "translation_records", force: :cascade do |t|
t.string "locale" t.string "locale"
t.integer "translator_id" t.integer "translator_id"
t.string "key" t.string "key"
t.text "value" t.text "value"
t.date "created_at" t.datetime "created_at"
end end
create_table "translations", force: :cascade do |t| create_table "translations", force: :cascade do |t|

Loading…
Cancel
Save