All threads / Forms With Multiple Submit Buttons Discussion

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Forms With Multiple Submit Buttons Discussion

Reply

Pretty cool!

Though will this work with translatable strings too? It doesn't seem like a really solid solution to this problem.

If you use the localize method in both places, it will work just fine for translatable strings. You just want to make sure you always keep them the same.

Roman Gaufman ·

Hmm, but the localised string can be different in the view compared to the controller, no? - also, what if you didn't get round to translating this specific string and it returns a placeholder text "to translate" for both buttons?

Reply
Евгений Арасланов ·
Reply

Hi! Learn to cause stored procedures in Rails please

Reply

Is this a good method? - What if you are using i18n so the commit message will show different languages?

Adam Cooper ·

At around 8 min he explains how to use the f.button instead of f.submit. Here the commit value has to be set manually. This way the button text can change, leaving the commit value the same,

Reply
Kohl Kohlbrenner ·

@excid3:disqus published_at is a column in your db. Is "published?" a rails method that looks at published_at as a boolean and returns true or false depending on if it is nil or not?

Yes, published_at is a column and published? Is just a method delegating to published_at? so it's more readable.

Reply
Reply
BronzeTax ·

Question, is it best practice to be putting the published? and save_as_draft? methods in your post controller? Or are you doing that for the sake of explaining it?

Reply

how can I add the validation of a field (unpublishing reason) by pressing the button unpublishing?

Reply
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,665+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.