Jump to content

The ultimate community for Ruby on Rails developers.


Photo

error when viewing show page


  • Please log in to reply
3 replies to this topic

#1 Ruegen

Ruegen

    Passenger

  • Members
  • 6 posts

Posted 17 August 2014 - 10:37 AM

I'm new to rails so I don't quite understand anything (explanations are helpful to me)

 

I am on the new page, underneath I list the made names and want to make them using

 

link_to item.firstname student_path

 

however when I get to the page I get this error...

 

undefined method `permit' for #<Student:0x00000105b711b8>
def show

    @student = Student.find(params[:id]).permit(:firstname,:lastname,:description)

end


#2 Ruegen

Ruegen

    Passenger

  • Members
  • 6 posts

Posted 17 August 2014 - 12:34 PM   Best Answer

nevermind, I shortened it to @student = Student.find(params[:id]) and it works now

 

although I'd like to know why still.



#3 Jamie

Jamie

    Controller

  • Moderators
  • 140 posts
  • LocationNewcastle, UK

Posted 17 August 2014 - 01:26 PM

permit isn't a defined method.

 

You can create an instance method in your Student model if you wish but the permit doesn't exist.

 

You maybe confusing permit params method which is used for strong parameters.

 

 

:)


Rails developer based in Newcastle, UK.


#4 Ohm

Ohm

    Driver

  • Moderators
  • 453 posts
  • LocationCopenhagen

Posted 17 August 2014 - 08:13 PM

It seems like you might be looking for the ActiveRecord::Relation method select, which does a SELECT SQL-query for you.


Blog: http://ohm.sh | Twitter: @madsohm | Work: Lokalebasen.dk





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users