Home>
I'm new to rails.
I created a new post screen and an edit screen with a partial template, but I want to change the characters displayed by the submit button depending on the file. Is it possible to display Create Book when posting a new post and Update Book when editing?
I want to specify the place to write the code in the if statement, but it doesn't work. What should I do?
<% = form_with model: book, local: true do | f |%>
<% = f.label: title%>
<% = f.text_field: title%>
<% = f.label: body%>
<% = f.text_area: body%>
<% = f.submit "Create Book"%>
<% end%>
* Since it is a partial template, the @ mark of the instance variable is deleted.
-
Answer # 1
Related articles
- ruby - partial template is not displayed (rails)
- ruby on rails - i want to reflect the partial template only when i am logged in
- ruby on rails - i want to change from the state where only one posted image is displayed to the state where two posted images ar
- javascript - how to insert a partial template on a ruby on rails js file
- ruby on rails 6 - i want to change the display of the product detail page according to the user's conditions
- ruby on rails - you cannot change the keychain after downloading the pem file when creating an ec2 instance the matter that come
- ruby on rails - i get a template is missing error in render
- ruby on rails 5 - actionview :: template :: error cannot be resolved
- ruby - [rails] about partial templates
- ruby on rails - variables are not passed to the partial template without reloading
- ruby on rails - i don't understand template is missing
- ruby on rails 5 - i want to change the location of views in rails 5
- ruby - [rails] i want to change the argument of link_to using conditional branching
- ruby - i want to call a partial template with the collection option so that the user detail page shows what the user posted
- ruby on rails - i get angry if there is no template in rails
- ruby on rails - i get an error in a program that changes over time
- about validation of ruby on rails
- ruby - the last db setting doesn't work when deploying rails app on aws
- ruby on rails - i want to sort the search results
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- 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
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
I remember a little, but I think you can do it below.
If the above doesn't work, you can do so by passing the new or edit flag when calling partial.
PostscriptI'm sorry, I made a mistake.
not
I think.
I remember getting the specified model object in the form_with block.
If you can not refer to it even above, it may be better to judge from the book object obediently.
like. .. ..
I've only been developing in API mode these days, so I've forgotten a lot ...