Cooking-like web services like cookpad are made with rails.
So I'm thinking about making a pasta-only page.
I want to realize where I search for data that has pasta in the chef column of the Cookings table and return name/image/text to the/cookings/pasta view using each statement.
It may be easy, but I would love to hear from you.
I don't get an error message, but I would like to erase the sequence that would have been received at @cookings = Cooking.where (chef: "pasta") at the end.
Applicable source code
def pasta @cookings = Cooking.where (chef: "pasta") end
<% = @ cookings.each do | cooking |%> <p><% = cooking.name%></p> <p><% = image_tag cooking.image.url%></p> <p><% = cooking.text%></p> <% end%>
Rails.application.routes.draw do devise_for: users # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root 'cookings # index' get '/ cookings/new' =>'cookings # new' post '/ cookings' =>'cookings # create' get '/ cookings/pasta' =>'cookings # pasta' end
binding.pry to confirm that the expected sequence is included in @cookings.
Without the each statement, the last array was never displayed.
Please provide more detailed information here.
Answer # 1
<% = @ cookings.each do | cooking |%>
<% =%>is used, the return value of
@cookingsitself) is output.
<%%>to embed without output.
- ruby - i want to display specific columns in rails in descending order of numbers
- ruby on rails - how to test that a specific element has a class name using rspec/capybara
- ruby - [rails 5] i want to send an email to a specific user using action mailer
- ruby on rails - i want to get data from a specific column and reflect it in the view
- ruby - i want to hide a specific record
- ruby on rails - extract multiple specific columns from one activerecord and make them json
- ruby on rails 5 - child model record not created
- ruby on rails 5 - the url when sign_up using device is strange
- ruby on rails - [rails] unintended action is called by the search function using jquery
- ruby - i want to know where to install rails gem and how to manage it
- ruby - i want to transition from create to show with rails
- ruby on rails - even if i fill in the message form and press the send button, it is not reflected in the view
- ruby on rails - about deploying apps using s3 function
- ruby on rails - [rails] i want to dynamically add and delete forms using cocoon
- ruby - when registering multiple images with rails, i would like to know the specific reason for managing the models separately
- ruby on rails 5 - "thin" error when installing gem
- ruby on rails 5 - the setup for everyday rails chapter 2 doesn't work (could not find shared context "project setup")
- ruby - pass the value from the controller in the rails model
- ruby on rails 5 - cannot check the existence of a child model that has a parent-child relationship
- ruby on rails - when i make a message, i want the date to be displayed, but i get "undefined method` strftime' for nil: nil
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- i want to call a child component method from a parent in vuejs