Skip to content

v0.3.8 - Magic Buttons

Compare
Choose a tag to compare
@jasonfb jasonfb released this 01 Jan 22:30
· 504 commits to main since this release

--magic-buttons
If you pass a list of magic buttons (separated by commas), they will appear in the button area on your list.

It will be assumed there will be corresponding bang methods on your models.

The bang methods can respond in one of four ways:

• With true, in which case a generic success message will be shown in the flash notice (“Approved” or “Rejected” in this case)
• With false, in which case a generic error message will be shown in the flash alert (“Could not approve…”)
• With a string, which will be assumed to be a “success” case, and will be passed to the front-end in the alert notice.
• Raise an ActiveRecord exception

This means you can be a somewhat lazy about your bang methods, but keep in mind the truth operator compares boolean true NOT any object is truth. So your return object must either be actually true (boolean), or an object that is string or string-like (responds to .to_s). Want to just say it didn’t work? Return false. Want to just say it was OK? Return true. Want to say it was successful but provide a more detailed response? Return a string.
Finally, you can raise an ActiveRecord error which will also get passed to the user, but in the flash alert area
For more information see Example 5 in the Tutorial


From the Tutorial
Screen Shot 2022-01-01 at 5 28 11 PM

Screen Shot 2022-01-01 at 5 28 27 PM
Screen Shot 2022-01-01 at 5 28 46 PM

PetitionApprovalableSystem 2021-12-13 10-26-03


Hot Glue Tutorial 

GET THE COURSE TODAY (includes Hot Glue License) only $60 USD!

Teachable-225x225 Now available on Teachable