Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
6 Cards in this Set
- Front
- Back
What are the naming conventions for Models?
|
Table is lower case, plural, underscore delimited: class_clowns
File is located at app/models, is singular and underscore delimited: class_clown.rb Class name singular is CamelCased: ClassClown |
|
What are the naming conventions for Controllers?
|
File is singular, underscore delimited (with _controller at the end) and stored in app/controller: store_controller.rb
Class is singular and CamelCased Layout is stored in app/views/layouts and be default is controllername.html.erb: store.html.erb |
|
What are the naming conventions for Views?
|
File is stored in app/view/controllername: app/views/store/list.html.erb
Helper is ControllerNameHelper (CamelCased) and stored in app/helpers/ and is underscore delimited: store_helper.rb |
|
How can you group controllers into Modules?
|
You can group controllers into Modules by putting them in separate folders in the app/controllers directory. The corresponding views have to match the folder structure too.
The controller generator can handle this: ruby script/generate controller Admin::Book action1 action2 |
|
How do you serialize an object with Rails?
|
You can serialize an object to yaml or json with to_json or to_yaml
|
|
What does the rails implementation of group_by do?
|
There a few built in RoR functions that are very useful for collections such as group_by. This function takes a code block and groups an array by some attribute or element:
groups = posts.group_by {|post| post.author_id} |