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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:30:47+00:00 2026-06-06T21:30:47+00:00

This is a noob question! How can I save the model Action, once when

  • 0

This is a noob question!

How can I save the model Action, once when I try to save in the controller, the params[:action] is taken by the action controller..

Here is my controller:

def viewTask()
  @id = params[:id]
  @task = Task.find(@id)
  @status = Status.find(@task.status_id)
  @actions = Action.where("task_id = #{@id}")
  @action = Action.new


  if params[:action]
    @action = Action.new(:message => params[:action], :task_id => @id)
    @action.save
  end
end

Here’s my view:

<%= form_for :action do |a| %>
  <%= a.text_area :message, :cols => 10, :rows => 5 %>
  <%= a.submit 'ok', :class=> "btn" %>
<% end %>

Thanks Everyone.

  • 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-06T21:30:48+00:00Added an answer on June 6, 2026 at 9:30 pm

    This answer is more like a comment, but it is so hard to understand, what the question is about, so I decided to have this as an answer.


    Come on, Fernando, how can we know what you’re trying to do? What action should the form be submitted to? Can you show us your routes.rb, so we know, how the action form can submit to your controller action. Maybe, to avoid problems with naming conventions in rails, you should rename your Action Model and Controller to something like Mission or Activity.

    What should your params Hash look like? Because there will always be a params[:action], that in case of a form normally is create or update.

    Further, please try to use the built in rails methods, like:

    # should be a POST method (am I right?)
    # why do you call it viewTask?
    
    def viewTask
      @task = Task.find(params[:id])
      # you'd better avoid extra DB-calls
      # @status = @task.status
      # @activities = @task.actions
    
      # you can load this with the @task-query by including or joining them
      # if you need the @status and @activities models you could do 
      # @task = Task.find(params[:id], :include => [:task, :activities]) 
    
      # if you only need the joined objects you should use
      @task = Task.find(params[:id], :joins => [:task, :activities]) 
    
      @activity = Activity.new
    
      if params[:activity]
        @activity = @task.activities.build(params[:activity])
        @activity.save
      end
    end
    

    In the code, I am assuming, that you’re task model looks something like this:

    class Task < ActiveRecord::Base
      has_many     :activities
      belongs_to   :status        # so it has a field called :status_id
      .....
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Noob question here. Please see code below. Where can I read more on this?
This might sound like a noob question, but here it goes anyway. Can BlackBerry
This is a noob question, but I can't get Valum's Uploader to work no
Real noob question no doubt, but I can't get my head around this behaviour.
i think this is a bit of a noob question, but here goes. I
Noob question here! I have an array with hashes that looks like this: arr
Hi Sorry for this noob question but here goes...i have a working slidetoggle on
This might be a noob question, but can't find an answer anywhere. I have
This is probably a noob question, but I can't seem to find the answer.
I have this (noob?) question, but i just can't figure it out for many

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.