Ruby On Rails Classroom image

Neha  Jaggi / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2|
Lessons:- Accessible Attributes and the First Validation

This code requires that the micropost be valid and tests for the presence of the user_id attribute. We can get these tests to pass with the simple presence validation shown in Listing 10.4.

 

 

Now we’re prepared to see why

@micropost =  Micropost . new ( content:  "Lorem ipsum", user id: user.id)

 

is wrong. The problem is that by default (as of Rails 3.2.3) all of the attributes for our Micropost model are accessible. As discussed in Section 6.1.2 and Section 9.4.1, this means that anyone could change any aspect of a micropost object simply by using a command-line client to issue malicious requests. For example, a malicious user could change the user_id attributes on microposts, thereby associating microposts with the wrong users. This means that weshould remove :user_id from the attr_accessible list, and once we do, the code above will fail. We’ll fix this issue in Section 10.1.3.  

 
 
 
image
Neha  Jaggi

Skills    Ruby On Rails

Qualifications :- High School - , College/University - Graphic Era Hill University, Dehradun, College/University - ,
Location :-Dehradun,Dehradun,UTTARAKHAND,India
Description:-

Experienced Software Developer with a demonstrated history of working in the Information Technology and services industry. Skilled in Web Technologies (Ruby on Rails, PostgreSQL, php, Laravel and AJAX). 


Explore
 

  Students (0)