Is it possible to instantiate a rails model (knowing its id) within an erb form.
I was doing it using haml as below and now wants to use erb forms.
- business_trip_request = BusinessTripRequest.find(id)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you can, but you should not. It is generally not good practice to violate the MVC structure. The view should not be accessing the database. You should let the controller load instance variables from the models, and let the view focus on just displaying it.
If you must do it, then try this in an html.erb file:
To display the id and the name fields(eg.):