Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

creating posts

  • Loading branch information...
commit 872613767735c2979c69057d55353447a6bdd4e4 1 parent eb39ad1
HugoLnx authored
2  .gitignore
View
@@ -2,3 +2,5 @@
db/*.sqlite3
log/*.log
tmp/
+*.swp
+*.swo
7 app/controllers/posts_controller.rb
View
@@ -0,0 +1,7 @@
+class PostsController < ApplicationController
+ def show
+ id = params[:id]
+ @post = Post.find id
+ render Dir["app/views/posts/#{sprintf('%.3d',@post.id)}-*"].first
+ end
+end
2  app/models/post.rb
View
@@ -0,0 +1,2 @@
+class Post < ActiveRecord::Base
+end
9 app/views/posts/001-ola_a_todos.html
View
@@ -0,0 +1,9 @@
+Olá, bem vindos ao meu blog, criei ele depois que o <a title="Anderson Leite" href="http://andersonleiteblog.wordpress.com/" target="_blank">anderson leite</a> quase me deu uma surra por eu não ter. xD
+
+Tentarei sempre postar algo que eu esteja fazendo(principalmente de ruby xD), ou notícias que eu ache interessante, ou seja,  tudo que eu estiver sabendo pretendo informar por aqui.=D
+
+Hoje não dará tempo, mas vo ver se logo amanhã posto uma tutorial de como compilar o arquivo .rb(em jruby) para um arquivo .class e roda-lo direto na JVM.xD
+
+Enfim.. Por hoje é isso, espero que gostem do que eu postar aqui.xD
+
+Obrigado e até mais =D
1  config/routes.rb
View
@@ -55,4 +55,5 @@
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
+ resources :posts
end
13 db/migrate/20110306213139_create_posts.rb
View
@@ -0,0 +1,13 @@
+class CreatePosts < ActiveRecord::Migration
+ def self.up
+ create_table :posts do |t|
+ t.string :title
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :posts
+ end
+end
21 db/schema.rb
View
@@ -0,0 +1,21 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20110306213139) do
+
+ create_table "posts", :force => true do |t|
+ t.string "title"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
BIN  public/images/rails.png
View
Deleted file not rendered
Please sign in to comment.
Something went wrong with that request. Please try again.