diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a86e5aa6..761ac2e9 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -12,9 +12,9 @@ class Mailer < ActionMailer::Base body :body => message.body, :sender => message.sender.nick, :recipients => recipient.nick, - :reply => "#{Foodsoft.config[:base_url]}/messages/reply/#{message.id}", - :link => "#{Foodsoft.config[:base_url]}/messages/show/#{message.id}", - :profile => "#{Foodsoft.config[:base_url]}/home/profile" + :reply => url_for(:controller => "messages", :action => "reply", :id => message.id), + :link => url_for(:controller => "messages", :action => "show", :id => message.id), + :profile => url_for(:controller => "home", :action => "profile") end # Sends an email with instructions on how to reset the password. @@ -23,7 +23,7 @@ class Mailer < ActionMailer::Base prepare_system_message(user) subject "[#{Foodsoft.config[:name]}] Neues Passwort für/ New password for #{user.nick}" body :user => user, - :link => "#{Foodsoft.config[:base_url]}/login/password/#{user.id}?token=#{user.reset_password_token}" + :link => url_for(:controller => "login", :action => "password", :id => user.id, :token => user.reset_password_token) end # Sends an invite email. @@ -31,7 +31,7 @@ class Mailer < ActionMailer::Base prepare_system_message(invite) subject "Einladung in die Foodcoop #{Foodsoft.config[:name]} - Invitation to the Foodcoop" body :invite => invite, - :link => "#{Foodsoft.config[:base_url]}/login/invite/#{invite.token}" + :link => url_for(:controller => "login", :action => "invite", :id => invite.token) end # Notify user of upcoming task. @@ -71,7 +71,7 @@ class Mailer < ActionMailer::Base prepare_system_message(user) subject "[#{Foodsoft.config[:name]}] #{task.name} braucht noch Leute!" body :task => task, :user => user, - :task_url => File.join(Foodsoft.config[:base_url], "tasks/workgroup", task.workgroup_id.to_s) + :task_url => url_for(:controller => "tasks", :action => "workgroup", :id => task.workgroup_id) end protected diff --git a/app/views/login/forgot_password.html.haml b/app/views/login/forgot_password.html.haml index 6d33cab0..0578df73 100644 --- a/app/views/login/forgot_password.html.haml +++ b/app/views/login/forgot_password.html.haml @@ -15,4 +15,4 @@ = text_field 'login', 'email' = submit_tag 'Neues Passwort anfordern' | - = link_to 'Abbrechen', :action => 'login' + = link_to 'Abbrechen', login_path diff --git a/app/views/login/password.html.haml b/app/views/login/password.html.haml index e85b79a0..b83e435a 100644 --- a/app/views/login/password.html.haml +++ b/app/views/login/password.html.haml @@ -13,4 +13,4 @@ = form.password_field :password_confirmation = form.submit 'Speichern' | - = link_to 'Abbrechen', :action => 'login' + = link_to 'Abbrechen', login_path diff --git a/app/views/mailer/not_enough_users_assigned.erb b/app/views/mailer/not_enough_users_assigned.erb index 9032b4f3..c85dd912 100644 --- a/app/views/mailer/not_enough_users_assigned.erb +++ b/app/views/mailer/not_enough_users_assigned.erb @@ -7,5 +7,5 @@ Sofern Du Dich noch nicht für diese Aufgabe eingetragen hast ist das jetzt die <%= @task_url %> -- -Deine Aufgaben: <%= Foodsoft.config[:base_url] %>/home/tasks +Deine Aufgaben: <%= url_for(:controller => "home", :actions => "user") %> diff --git a/app/views/mailer/order_result.html.erb b/app/views/mailer/order_result.html.erb index 1b0bbc6b..6381856f 100644 --- a/app/views/mailer/order_result.html.erb +++ b/app/views/mailer/order_result.html.erb @@ -9,6 +9,6 @@ Für Euch wurden die folgenden Artikel bestellt: <% end -%> Gesamtpreis: <%= @group_order.price %> -Bestellung online einsehen: <%= "#{Foodsoft.config[:base_url]}/ordering/my_order_result/#{@order.id}" %> +Bestellung online einsehen: <%= url_for(:controller => "ordering", :action => "my_order_result", :id => @order.id) %> Viele Grüße von <%= Foodsoft.config[:name] %> \ No newline at end of file diff --git a/app/views/mailer/upcoming_tasks.html.erb b/app/views/mailer/upcoming_tasks.html.erb index b310b710..cadeddf5 100644 --- a/app/views/mailer/upcoming_tasks.html.erb +++ b/app/views/mailer/upcoming_tasks.html.erb @@ -11,6 +11,6 @@ Aufgaben für die nächste Woche: <% end -%> <% end -%> -Meine Aufgaben: <%= Foodsoft.config[:base_url] %>/home/tasks +Meine Aufgaben: <%= url_for(:controller => "home", :actions => "user") %> Viele Grüße von <%= Foodsoft.config[:name] %> \ No newline at end of file diff --git a/config/app_config.yml.SAMPLE b/config/app_config.yml.SAMPLE index 911c43f1..d5043011 100644 --- a/config/app_config.yml.SAMPLE +++ b/config/app_config.yml.SAMPLE @@ -5,6 +5,12 @@ development: &defaults # Don't forget to setup databases for each foodcoop. See also MULTI_COOP_INSTALL multi_coop_install: false + # http config for this host + # Required for action mailer + protocol: http + host: localhost + port: 3000 + # name of this foodcoop name: FC Test # foodcoop contact information (used for FAX messages) diff --git a/config/initializers/load_app_config.rb b/config/initializers/load_app_config.rb index 53e9d938..ed3ff403 100644 --- a/config/initializers/load_app_config.rb +++ b/config/initializers/load_app_config.rb @@ -17,6 +17,13 @@ end # Initial load the default config and database from rails environment Foodsoft.env = RAILS_ENV +# Set action mailer default host for url generating +ActionMailer::Base.default_url_options = { + :host => Foodsoft.config[:host], + :port => Foodsoft.config[:port], + :protocol => Foodsoft.config[:protocol] +} + # Configuration of the exception_notification plugin # Mailadresses are set in config/foodsoft.yaml ExceptionNotifier.exception_recipients = Foodsoft.config[:notification]['error_recipients'] diff --git a/config/routes.rb b/config/routes.rb index 8eee3473..547f8509 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,7 @@ ActionController::Routing::Routes.draw do |map| map.root :controller => 'home', :action => 'index' # User specific + map.login "/login", :controller => 'login', :action => 'login' map.logout '/logout', :controller => 'login', :action => 'logout' map.my_profile '/home/profile', :controller => 'home', :action => 'profile' map.my_ordergroup '/home/ordergroup', :controller => 'home', :action => 'ordergroup'