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 9113337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:56:30+00:00 2026-06-17T03:56:30+00:00

I don’t want to use the default <%= f.submit %> and have created a

  • 0

I don’t want to use the default

<%= f.submit %>

and have created a helper function for it, which also embeds an icon. The helper function expects a label to put on the newly created button.

I’m calling it like this:

<%= submit_button("icon-plus", I18n.translate("helpers.submit.create")) %>

But now on this text appears on the button:

%{model} toevoegen

Instead of:

Product type toevoegen

If I use the normal submit button then the correct text appears so my yml files are correct. How can I get the correct text to use in the helper?

Helper code:

def submit_button(icon, label)
  link_to "javascript:void(0)", :class => 'btn btn-primary', :onclick => "$(this).closest('form').submit()" do
  raw('<div class="') + icon + raw(' icon-white"> ') + label +raw('</div>')
  end
end
  • 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-06-17T03:56:31+00:00Added an answer on June 17, 2026 at 3:56 am

    As the I18n guide says, the translate function interpolates variables passed in the %{} brackets using its second argument (a hash).

    In your case you need to tell it the model by doing this:

    I18n.t("helpers.submit.create", model: "Product type")
    

    If you want a generic option that would work for any model, you can see how Rails itself does it by looking at the source on GitHub – it’s something like

    I18n.t("helpers.submit.create", model: f.object.class.model_name.human)
    

    As an aside, you don’t need to (and probably shouldn’t) use raw there. What you are trying to achieve could easily be done with the built-in helpers:

    link_to ... do
      content_tag :div, label, class: "#{icon} icon-white"
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know if it's stupid or reasonable question. I have methods which returns float/int
Don't ask me how but I'm in a situation where I have DCPs published
Don't ask why but I have the requirement to draw a border around certain
Don't be afraid to use any technical jargon or low-level explanations for things, please.
Don't they both have to convert to machine code at some point to execute
I don't want to raise this as an issue, because it seems like a
Don't overthink this - there's a very commonly used term and I ... have
Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't think my virtualhost is working correctly. This is what I have inside of
Don't know why, but sometimes LocationManager is still working also after closing application. I

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.