On 19 May 2016 at 21:58, Deepak Sharma <deeky.sharma@gmail.com> wrote:
>
> On Fri, May 20, 2016 at 1:50 AM, Colin Law <clanlaw@gmail.com> wrote:
>>
>>
>> Initially what you are doing wrong is not posting the full error
>> message and not telling us which line of code the error refers to.
>> The error means that you have tried to call something.user_id but the
>> value of 'something' is nil. Look at the line of code the error
>> refers to and try to work out why the variable is nil.
>
> I'm getting an error message because of following statement
>
> <!-- Else If Statement -->
>
> <% elsif @student.user_id == current_user.id %>
> ...
> <% end %>
>
> @student.user_id not working. But in DB id's are not empty and user_id also
> exists in student's table.
Note that here you have put @student.user_id
>
>
> If I go like this
>
> <% @students.each do |student| %>
> <% elsif student.user_id == current_user.id %>
Also note that her you have said student.user_id (no '@')
In the code you posted initially it is @student, which is nil as you
have not assigned a value to it.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuXYbSNhsrAttBVPCP4jDEgTW61T9GcHg_BvytsDyPhbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment