Ruby on Rails
Thursday, May 19, 2016
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 %>
Another User:
Show (Current User profile)
--
Cheers!
Deepak Kumar Sharma
Guru Nanak Dev Engineering College
India!
Blog: http://deekysharma.wordpress.com
...
<% end %>
@student.user_id not working. But in DB id's are not empty and user_id also exists in student's table.
If I go like this
<% @students.each do |student| %>
<% elsif student.user_id == current_user.id %>
...
<%end %>
<% end %>
Intially everything woks fine. Current user able to edit, delete and show his profile and other user's able to show it only (i.e only show button appear). Else and Elsif statements works fine. But when another user add his data and after saving he's able to edit and delete current user' data.
Case 1: (Current user add his data)
Current User:
Show | Delete | Edit
Another User:
Show (Current User profile)
Case 2: (When another user enters his data and after saving it)
Current User:
Current User:
Show | Edit | Delete
Another User:
Show | Edit | Delete (Current User profile)
Another User:
Show | Edit | Delete (Current User profile)
--
Cheers!
Deepak Kumar Sharma
Guru Nanak Dev Engineering College
India!
Blog: http://deekysharma.wordpress.com
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/CALDHwN5-M9ZptGeOrgR78jYUWxBa42bYo67sN-E6RfYnDMsZDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment