I want to create a button with the help of the button_to method to navigate to a page where a new user friendship can be created.
<%= button_to t(:add_friend), new_user_friendship_url(current_user), :method => :get, :class => "btn-success" %>
(I do not want to use a link, i.e. not use link_to, because the styling of the buttons of the CSS framework I use look much better than the links).
Unfortunately, the button_to does not append the right locale as URL parameter. Is there anything I can do about it?
This is my application_controller.rb where I set the locale for every page request.
class ApplicationController < ActionController::Base
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
protect_from_forgery
def default_url_options(options={})
logger.debug "default_url_options is passed options: #{options.inspect}\n"
{ :locale => I18n.locale }
end
end
Thanks for suggestions.
first of all, it should be easy to style buttons the same way links are styled.
secondly, i think that the problem is somewhere else in your code. if i put this in my app:
i get a form like:
and this button takes me to
http://localhost:5000/users?locale=de