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
| validates :name, presence: true, length: {maximum: 50} | |
| VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i | |
| validates :email, presence: true , format: { with: VALID_EMAIL_REGEX } |
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
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/html"> | |
| <head> | |
| <title><%= full_title(yield(:title)) %></title> | |
| <%= stylesheet_link_tag "application", :media => "all" %> | |
| <%= javascript_include_tag "application" %> | |
| <%= csrf_meta_tags %> | |
| <%= render 'layouts/shim' %> | |
| </head> | |
| <body> |
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
| # MySQL. Versions 4.1 and 5.0 are recommended. | |
| # | |
| # Install the MYSQL driver | |
| # gem install mysql2 | |
| # | |
| # Ensure the MySQL gem is defined in your Gemfile | |
| # gem 'mysql2' | |
| # | |
| # And be sure to use new-style password hashing: | |
| # http://dev.mysql.com/doc/refman/5.0/en/old-client.html |
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 create def is a default just like show so you must use it | |
| # And you would use it when handling the submission of forms created | |
| # inside of the Controller for users | |
| def create | |
| # This code is run on the submission of our create form | |
| @user = User.new(params[:user]) | |
| if @user.save | |
| # This code is executed on a valid save | |
| redirect_to @user |
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 Flash item is a temporary space used within Ruby | |
| In this case we are using it to display status messages accross | |
| The ruby site We are using a loop to do it--> | |
| <% flash.each do |key, value| %> | |
| <div class="alert alert-<%= key %>"><%= value %></div> | |
| <% 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
| # Sample localization file for English. Add more files in this directory for other locales. | |
| # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. | |
| # When an active record error message is show it uses the column name for the validation error | |
| # In the case of non English column names we need to create a name alias. In this case we are | |
| # changing the column name password_digest. We are giving it the Alias of 'Password' | |
| en: | |
| activerecord: | |
| attributes: |
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
| # An example of passing a value to a method within a class directly | |
| def gravatar_for(user, options = { size: 50 }) | |
| gravatar_id = Digest::MD5::hexdigest(user.email.downcase) | |
| gravatar_url = "http://www.gravatar.com/avatar/#{gravatar_id}.jpg?s=#{size}" | |
| image_tag(gravatar_url, alt: user.name, class: "gravatar") | |
| 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
| <% provide(:article_heading, 'Contact NùRùmie'.html_safe) %> |
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
| <%= model.field.blank? ? 'Fill In' : model.field %> |
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
| # MySQL. Versions 4.1 and 5.0 are recommended. | |
| # | |
| # Install the MYSQL driver | |
| # gem install mysql2 | |
| # | |
| # Ensure the MySQL gem is defined in your Gemfile | |
| # gem 'mysql2' | |
| # | |
| # And be sure to use new-style password hashing: | |
| # http://dev.mysql.com/doc/refman/5.0/en/old-client.html |