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
| class HashWithDotNotation < Hash | |
| def initialize(constructor = {}) | |
| if constructor.is_a?(Hash) | |
| super() | |
| self.replace(constructor) | |
| else | |
| super(constructor) | |
| end | |
| 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
| /* RESET STYLES FROM BLUEPRINT */ | |
| html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;} | |
| body {line-height:1.5;} | |
| table {border-collapse:separate;border-spacing:0;} | |
| caption, th, td {text-align:left;font-weight:normal;} | |
| table, td, th {vertical-align:middle;} | |
| blockquote:before, blockquote:after, q:before, q:after {content:"";} | |
| blockquote, q {quotes:"" "";} | |
| a img {border:none;} |
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
| # bundle_path "vendor/bundler_gems" #Will be vendor/gems in RAILS 3 | |
| #disable_system_gems | |
| source :gemcutter | |
| gem "rails", "2.3.5" | |
| gem 'mysql' | |
| gem "compass", "0.8.17" | |
| gem "haml", "2.2.10" | |
| gem "will_paginate", "2.3.11" | |
| gem "aws-s3", "0.6.2", :require => "aws/s3" |
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
| require File.expand_path('../boot', __FILE__) | |
| require 'rails/all' | |
| # If you have a Gemfile, require the gems listed there, including any gems | |
| # you've limited to :test, :development, or :production. | |
| Bundler.require(:default, Rails.env) if defined?(Bundler) | |
| module Blog | |
| class Application < Rails::Application |
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
| pt-br: | |
| general: | |
| are_you_sure: Tem certeza? | |
| back: Volta | |
| cancel: Cancelar | |
| create: Criar | |
| delete: Apagar | |
| edit: Editar | |
| editing: Editando | |
| footer: Um blog simples desenvolvido para o livro |
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
| class Notifier < ActionMailer::Base | |
| default :from => "from@example.com" | |
| def email_friend(article, sender_name, receiver_email) | |
| @article = article | |
| @sender_name = sender_name | |
| mail :to => receiver_email, :subject => "Interesting Article" | |
| end | |
| 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
| <%= div_for comment do %> | |
| <h3> | |
| <%= comment.name %> <<%= comment.email %>> said: | |
| <% if @article.owned_by? current_user %> | |
| <span class='actions'> | |
| <%= link_to 'Delete', [@article, comment], :confirm => 'Are you sure?', :method => :delete %> | |
| </span> | |
| <% end %> | |
| </h3> | |
| <%= comment.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
| class CommentsController < ApplicationController | |
| before_filter :load_article, :except => :destroy | |
| before_filter :authenticate, :only => :destroy | |
| def create | |
| @comment = @article.comments.new(params[:comment]) | |
| if @comment.save | |
| redirect_to @article, :notice => 'Thanks for your comment' | |
| else | |
| redirect_to @article, :alert => 'Unable to add comment' |
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
| class Article < ActiveRecord::Base | |
| validates :title, :presence => true | |
| validates :body, :presence => true | |
| belongs_to :user | |
| has_and_belongs_to_many :categories | |
| has_many :comments | |
| scope :published, where("articles.published_at IS NOT NULL") | |
| scope :draft, where("articles.published_at IS NULL") |
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> | |
| <head> | |
| <title>Blog</title> | |
| <%= stylesheet_link_tag :all %> | |
| <%= javascript_include_tag :defaults %> | |
| <%= csrf_meta_tag %> | |
| </head> | |
| <body> |