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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:49:18+00:00 2026-05-11T02:49:18+00:00

One of the things I’m doing includes several links on the show view. For

  • 0

One of the things I’m doing includes several links on the show view. For instance, I have a link (or button) for ‘Accepting’, and another one for ‘Rejecting’. Click on Accept, and the model updates the is_accepted field as true, click on Reject, and the is_accepted field is false.

Now, how best do I handle this? In ASP.NET, I would have simply created a LinkButton and written a handler, but Rails doesn’t work that way, so I’m trying to figure out how to essentially replicate what a LinkButton would do.

Right now, I’m coding two forms on the same view, nearly identical, that look like this:

<%= form_for @thing do |f| %>   <%= hidden_field_tag 'thing[is_accepted]', '1' %>   <%= f.submit 'Accept' %> <% end %> <%= form_for @thing do |f| %>   <%= hidden_field_tag 'thing[is_accepted]', '0' %>   <%= f.submit 'Reject' %> <% end %> 

This feels weird to me, but I can’t seem to find anything that says this is the wrong way to do it.

I could, I assume, dry things up by using a partial and/or a helper method, but I wanted to make sure I’m on the right track and not doing something totally wrongly.

  • 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. 2026-05-11T02:49:18+00:00Added an answer on May 11, 2026 at 2:49 am

    I think you’re going about it the right way. One way to clean up your forms is by using the model form helpers all the way through, so you’d end up with something like

    <%= form_for @thing do |f| %>   <%= f.hidden_field :accepted, :value => true %>   <%= f.submit 'Accept' %> <% end %>  <%= form_for @thing do |f| %>   <%= f.hidden_field :accepted, :value => false %>   <%= f.submit 'Reject' %> <% end %> 

    But other than that, it looks like the right way to go about it. I would suggest against creating new methods to do this, because you’re not doing anything outside of normal web requests (updating a model in this instance).

    Using the submit tag as the switch and detecting it in params[] is also a good way, but I usually prefer to keep my controllers as vanilla as possible. In the end, both of these ways would end up with the same amount of ‘stuff’ in the UI, so whichever style you’d rather use should be fine.

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

Sidebar

Related Questions

Recently I found out that there are several things that one can do to
For an art project, one of the things I'll be doing is zooming in
So I have testfile which contains Line one Another line and this is the
i have noticed one things , when some website are opened in any browser
i notice one nice things that a amazon provide that is load pdf data
Apparently MapReduce queries are one of the slowest things one can do in MongoDB
One of the things that block objects, introduced in Snow Leopard, are good for
One of the things I would like to follow is to stick to the
One of the things I love is the new Android Favorites Contact screen: I
This is one of those things that you read once, say aha! and then

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.