This file contains 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 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 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 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 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 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 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 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> |
This file contains 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 'jquery-1.4.2.min', 'rails', 'application' %> | |
<%= csrf_meta_tag %> | |
</head> | |
<body> | |
<div id="header"> |
This file contains 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
<%= form_tag search_articles_path, :method => :get do %> | |
<p> | |
Search | |
<%= text_field_tag :keyword, params[:keyword] %> | |
</p> | |
<% end %> |