Permalink
Browse files

Adding globalize3, friendlyid and small rdiscount support (no cache)

  • Loading branch information...
1 parent d997162 commit 0ff7071d72daa73e48fc497fe8034f46d1e16b5b @akitaonrails committed Jul 13, 2012
View
@@ -22,6 +22,9 @@ end
gem 'jquery-rails'
gem 'rails-translate-routes'
+gem 'globalize3'
+gem 'friendly_id'
+gem 'rdiscount'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
View
@@ -48,6 +48,11 @@ GEM
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
+ friendly_id (4.0.7)
+ globalize3 (0.2.0)
+ activemodel (>= 3.0.0)
+ activerecord (>= 3.0.0)
+ paper_trail (~> 2)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
@@ -63,6 +68,9 @@ GEM
mime-types (1.19)
multi_json (1.3.6)
orm_adapter (0.3.0)
+ paper_trail (2.6.3)
+ activerecord (~> 3.0)
+ railties (~> 3.0)
polyglot (0.3.3)
pry (0.9.9.6)
coderay (~> 1.0.5)
@@ -95,6 +103,7 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
+ rdiscount (1.6.8)
rdoc (3.12)
json (~> 1.4)
rspec (2.10.0)
@@ -139,10 +148,13 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 3.2.1)
devise
+ friendly_id
+ globalize3
jquery-rails
pry-rails
rails (= 3.2.6)
rails-translate-routes
+ rdiscount
rspec-rails
sass-rails (~> 3.2.3)
sqlite3
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,3 @@
+// Place all the styles related to the articles controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,6 @@
+class ArticlesController < ApplicationController
+ def show
+ @article = Article.find(params[:id])
+ @body_html = RDiscount.new(@article.body || "").to_html
+ end
+end
@@ -0,0 +1,2 @@
+module ArticlesHelper
+end
View
@@ -0,0 +1,17 @@
+class Article < ActiveRecord::Base
+ attr_accessible :body, :slug, :title, :locale
+ extend FriendlyId
+ friendly_id :title, use: :slugged
+
+ translates :title, :body
+
+ class Translation
+ attr_accessible :locale
+ end
+
+private
+
+ def should_generate_new_friendly_id?
+ new_record?
+ end
+end
@@ -0,0 +1,3 @@
+<h1><%= @article.title %></h1>
+
+<%=raw @article.body %>
@@ -1,12 +1,7 @@
-<h1>Welcome#index</h1>
-
-<p>
- <%= t("hello") %>
-</p>
+<h1>Articles</h1>
<ul>
- <li><%= number_to_currency(100.0) %></li>
- <li><%= l(Time.current, :format => :long) %></li>
- <li><%= distance_of_time_in_words Time.now, Time.now + 2.hours %></li>
- <li><%= User.human_attribute_name(:password) %></li>
+ <% Article.all.each do |article| %>
+ <li><%= link_to article.title, article_path(article.slug) %></li>
+ <% end %>
</ul>
@@ -10,3 +10,5 @@ pt-BR:
sign_in: login
users: usuarios
cancel: cancelar
+ article: artigo
+ articles: artigos
View
@@ -1,5 +1,8 @@
I18nDemo::Application.routes.draw do
+ get "articles/show"
+
devise_for :users
+ resources :articles
get "welcome/index", as: "welcome"
root to: 'welcome#index'
end
@@ -0,0 +1,16 @@
+class CreateArticles < ActiveRecord::Migration
+ def up
+ create_table :articles do |t|
+ t.string :slug, null: false
+ t.timestamps
+ end
+ add_index :articles, :slug, unique: true
+
+ Article.create_translation_table! :title => :string, :body => :text
+ end
+
+ def down
+ drop_table :articles
+ Article.drop_translation_table!
+ end
+end
View
@@ -11,7 +11,27 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120712230107) do
+ActiveRecord::Schema.define(:version => 20120713201558) do
+
+ create_table "article_translations", :force => true do |t|
+ t.integer "article_id"
+ t.string "locale"
+ t.string "title"
+ t.text "body"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "article_translations", ["article_id"], :name => "index_article_translations_on_article_id"
+ add_index "article_translations", ["locale"], :name => "index_article_translations_on_locale"
+
+ create_table "articles", :force => true do |t|
+ t.string "slug", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "articles", ["slug"], :name => "index_articles_on_slug", :unique => true
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
Oops, something went wrong.

0 comments on commit 0ff7071

Please sign in to comment.