Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7603695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:43:16+00:00 2026-05-30T23:43:16+00:00

I want to create a button with the help of the button_to method to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:43:17+00:00Added an answer on May 30, 2026 at 11:43 pm

    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:

    = button_to 'blaa', users_path(:locale => 'de')
    

    i get a form like:

    <form action="/users?locale=de" class="button_to" method="post"><div><input type="submit" value="blaa" /><input name="authenticity_token" type="hidden" value="k4PtVPS041DnTmTqkfh+xBIyFvVJCauenmg233BoLSw=" /></div></form>
    

    and this button takes me to http://localhost:5000/users?locale=de

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a button that has a jQuery click on the fly.
I want to create a Button otherthan creating it from xml layout.i want to
I want to create PayPal button with dynamic price (depending from the item) and
i want to create a button/menu in title bar on each windows explore(or in
I want to create a toggle button in html using css. I want it
I want to create some up and down buttons using the standard button background
I want to create a search box with the search button directly to the
I want to create a Toolbar in my application. If you click a button
I want to create a textbox, which can be edited and shows the text
I want to create a custom button in ActionScript. This is my code: import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.