I ...">

Strange error viewing user rights

When I click on this link in my index view:

 <%= link_to "Edit Password", edit_user_path(current_user) %> 

I get this error:

 NoMethodError in Users#edit Showing /rubyprograms/dreamstill/app/views/videos/_modal.html.erb where line #3 raised: undefined method `model_name' for NilClass:Class Extracted source (around line #3): 1: <div id="boxes"> 2: <div id="dialog" class="window"> 3: <%= form_for(@video) do |f| %> 

This is due to the partial name _modal , which I render in the index view. It has a form.

I also have this in the video controller:

 def index @video = Video.new @videos = Video.paginate(:page => params[:page], :per_page => 20) end 

Why am I getting this error and how to fix it?

UPDATE:

Here is my editing action in the Users controller:

 def edit @user = current_user end 

Here's the _modal partial:

 <div id="boxes"> <div id="dialog" class="window"> <%= form_for(@video) do |f| %> <% if @video.errors.any? %> <div id="errorExplanation"> <h2><%= pluralize(@video.errors.count, "error") %> prohibited this video from being saved:</h2> <ul> <% @video.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :video_url %><br /> <%= f.text_field :video_url %> </div> <div class="field"> <%= f.label :title, 'Song Title' %><br /> <%= f.text_field :title %> </div> <div class="actions"> <%= f.submit %> </div> <% end %> <%= link_to 'Cancel', '#', :class => 'close' %> </div> <div id="mask"></div> </div> 
0
source share
1 answer

I believe that basically you have the same problem as last time.

Since you are effectively performing the edit action, whether modal or not, you need to define @video again.

+2
source

Source: https://habr.com/ru/post/1345036/


All Articles