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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:48:33+00:00 2026-05-28T22:48:33+00:00

In my controller i have two actions: Select_users and Make_something . In Select_users i

  • 0

In my controller i have two actions: "Select_users" and "Make_something".
In “Select_users” i get a @var with a list of users (this users are generated from a search with a form in the same view) and i need to make an insert for each of those … like:

   @var.each do |v|
     Table.create(:atribute => v.name)
   end

When i have my list of selected users i use a Submit button to send me to the “Make_something” action.

So i was thinking to “pass” the @var variable to the “Make_something” action to make this create, but I can’t use @var in “Make_something” because it’s accesible only in “Select_users”.

I read about filters but i think they cant help me with this problem.

Thanks!

  • 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-28T22:48:34+00:00Added an answer on May 28, 2026 at 10:48 pm

    If you have code common to several methods, extract it out to another method.

    def select_users
      @var = go_get_those_users
    end
    
    def make_something
      go_get_those_users.each do |v| Table.create(:atribute => v.name) end
    end
    
    private
    def go_get_those_users
      # do whatever you need to populate your collection
      return [] 
    end
    

    Alternatively, you could pass the list of IDs of the selected users in the form that posts to “make_something”. Or if you really want to persist this somehow (I assume this is some form of “multi-step form wizard” of some description), user the db, not the session – have a “wizard” model that is retained in the DB. Each step would then pass the wizard_id, and save its own values to the wizard – this could have normal AR associations (for your selected users) through relationships.

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

Sidebar

Related Questions

I have a controller with two different actions, but both need this same code,
I have two actions in controller: function indexAction() { $this->_redirect('/index/welcome/'); } function welcomeAction() {
I have the following two actions in my controller: function add() { if (!empty($this->data))
I have two view controller classes in my application delegate. I can change from
I have two combobox. I need get some value from first combobox1 after combobox1
I have two actions inside my controller (shoppingCartController) public ActionResult Index() { //some stuff
I have a dropdown list that auto submits a form and performs a search
Can somebody explain me one thing. I have two methods in my controller :
I have a Controller with two Edit methods (see below). When I submit the
I have a NIB with two NSWindow objects. The controller class has two IBOutlets,

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.