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

  • Home
  • SEARCH
  • 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 6752139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:00:35+00:00 2026-05-26T13:00:35+00:00

i have 2 controllers methods create and show def create @message2 = Message.new(params[:message]) if

  • 0

i have 2 controllers methods create and show

def create
   @message2 = Message.new(params[:message])
   if @message2.valid?
   @message2 = current_user.sent_messages.create(params[:message])         
      redirect_to @message2.receiver    
    else
      redirect_to :back
    end
end

and

def show

   @message = Message.find(params[:id])
   if current_user==@message.receiver
     @message.is_read=true
     @message.save
     @message2=Message.new(:receiver_id=>@message.sender, :sender_id=>current_user,:theme=>@message.theme)
   else
     @message2=Message.new(:receiver_id=>@message.receiver, :sender_id=>current_user,:theme=>@message.theme)
   end


end

my form

= form_for(@message2) do |f|

  %p
    Content:
    %br
    = f.text_area :content ,:rows => 5,:id => "text_area",
                :cols => 45

  .actions
    = f.submit

in show view i have form which initialize @message2.content but create action cleans all parameters which I set in show action and sets only content value. How to make my form to append parameters (not to clean old)?

  • 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-26T13:00:35+00:00Added an answer on May 26, 2026 at 1:00 pm
    def create
      @message2 = current_user.sent_messages.new(params[:message])         
      if @message2.save
        redirect_to @message2.receiver    
      else
        render :action => :show
      end
    end
    

    Here’s how your create action should look. This is a commonly used Rails idiom.

    It will render the form correctly, because the instance variable is still there.

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

Sidebar

Related Questions

I have a model called Details, and two controller methods new and create. New
I have the following code: def show @game = $site.new_game_of_type(params[:id]) @game.start end def update_game_time
I have created a new method in one of the project's controllers that it
ASP.Net MVC Controllers have several methods of forwarding control to another controller or action.
I have several links I'm trying to create to either perform custom controller methods
I would like to have 4 actions with the same name (controller methods may
I have a Controller with two Edit methods (see below). When I submit the
I have a few methods inside my view controller that load up for future
Can somebody explain me one thing. I have two methods in my controller :
If you have a controller method like so: @expose(json) def artists(self, action=view,artist_id=None): artists=session.query(model.Artist).all() return

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.