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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:16:06+00:00 2026-05-27T21:16:06+00:00

I have this table where you add taxes. |Name | Rate | Description |

  • 0

I have this table where you add taxes.

|Name | Rate | Description |
|IVA  |  16  | something   |
|     |      |             |
|     |      |             |
|     |      |             |
save

So if you hit save, it will save the new items entered. I had to do this in taxes_controller.rb

@account = Account.find(current_user.account_id)
3.times {@account.taxes.build}

Then this in the form

<%= form_for(@account) do |f| %>
<table style="width:400px;" class="taxes">
  <tr>
    <th>Name</th>
    <th>Rate</th>
    <th>Description</th>
  </tr>

<%= f.fields_for :taxes do |builder| %>
  <tr>
    <td><%= builder.text_field :name %></td>
    <td><%= builder.text_field :rate %> %</td>
    <td><%= builder.text_field :identification %></td>
  </tr>
<% end %>
...

When I submit the form, the fields do get saved in the database. The problem is that it redirects to the Account show page; and I understand it has to do that because of form_for(@account).

So the question is: how can I specify where I want the form to redirect after submission. In this case, I want to redirect it to the currect page.

  • 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-27T21:16:06+00:00Added an answer on May 27, 2026 at 9:16 pm

    It’s only indirectly because of form_for(@account).

    When you post your form, it hits the create (or update) action of the accounts_controller.

    So it’s in these 2 actions (create and update) of this controller that you should do a redirect_to ....

    You say that you want to redirect to the current page. What is the current page exactly?


    Ok, so what you can do is add this to your routes:

    resources :accounts, :module => "taxes"
    

    And your form would become

    form_for [:taxes, @account] ... do |f|
    

    Your controller would be in app/controllers/taxes/accounts_controller.rb

    class Taxes::AccountsController < ::AccountsController
        def edit
    
        end
    
        def update
            ...
            redirect_to taxes_url
        end
    end
    

    So you’d have to change your form with this method. You could pass the path ([@account] or [:taxes, @account]) as an argument of your partial…

    Another solution, maybe simpler, would be to just have a redirect_to input in your form. You set it only when you use your form in taxes. And in the controller, unless params[:redirect_to].blank?; redirect_to params[:redirect_to] end…

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

Sidebar

Related Questions

This is the constraint I have on the Customers table. ALTER TABLE Customers ADD
I have this table in an Oracle DB which has a primary key defined
I have this table CREATE TABLE [dbo].[friend_blocked_list]( [subdomain] [varchar](50) NOT NULL, [un] [nvarchar](50) NOT
I have this table CREATE TABLE `codes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
i have this table in UTF8 (collation is utf8_bin in case it matters). I
I have this table: CREATE TABLE `test` ( `ID` int(11) NOT NULL auto_increment, `text`
I have this table: fourn_category (id , sub) I am using this code to
I have this table: CREATE TABLE `point` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `siteid`
I have this table: id feed_id ... Let's say that I have 500 rows
I have this table structure and would like to map it using Fluent Hibernate

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.