This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #To set the root of your app delete the index.html file within the | |
| #public folder then use the below | |
| root to: 'static_pages#home' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Creating better Routes. In rails you match the URI to the controller | |
| # and then the action within the controller, this allows you to make bases URLs | |
| # This creates a route that can also be referenced within code as the following | |
| # contact_path = /contact | |
| # contact_url = http://localhost/contact/ | |
| match '/contact', to 'static_pages#contact' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!--The render command is used by rails to call shims and render them inside of your views--> | |
| <!--shims have to be named the following _shimname.html.erb--> | |
| <%= render 'layouts/header' %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org' %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user_input = "foo,bar,you,know".split(',') # We use split to make an array from user input | |
| user_input.count # this will display 4 because we store 4 values in our array | |
| # Now we use the temp array sort method | |
| user_input.sort | |
| # To save the values back to the array you need to use ! | |
| user_input.sort! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Displays the current date but repeat x times | |
| def display_time(how_many_times) | |
| p = how_many_times.to_i | |
| return p.times {puts Time.now.strftime("%m/%d/%y")} | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def full_title(page_title) | |
| base_title = "Ruby on Rails Tutorial Sample App" | |
| if page_title.empty? | |
| base_title | |
| else | |
| "#{base_title} | #{page_title}" | |
| end | |
| end |
NewerOlder