Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Information from one action to another

Controllers Instance Variables

  • Please log in to reply
No replies to this topic

#1 alphajackson3

alphajackson3

    Passenger

  • Members
  • 4 posts

Posted 19 March 2014 - 03:17 AM

I'm still fairly new to rails and I have what is probably an easy question to answer.  So I'm trying to build a simple video upload application. I've decided to go with paperclip to deal with the video attachment. Once the app redirects after the save I would like to have access to the @video variable or maybe or maybe another instance variable that is in the create action in the view that I am redirecting to.

 

My form in the new view looks like this

 

<%= form_for(@video) do |f| %>
  <%= f.file_field :video %>
  <%=f.text_field :video_title%>
  <%= f.submit "Upload" %>
<% end %>

 

My ClipUpload controller

 

def new
    @video = ClipUpload.new
  end

 

def create
    @video = ClipUpload.new(clip_upload_params)

     if@video.save
    
        redirect_to clip_uploads_path, :notice =>   "Upload worked"
    end
  end

 

private

    def clip_upload_params
      params.require(:clip_upload).permit(:video, :video_title, :video_file_name)
      
    end

 

thanks







Also tagged with one or more of these keywords: Controllers, Instance Variables

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users