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 CreateBlogPosts < ActiveRecord::Migration | |
def self.up | |
create_table :blog_posts do |t| | |
t.string :subject | |
t.text :content | |
t.string :tag | |
t.timestamps | |
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
class CommentsController < ApplicationController | |
before_filter :blogpost_find, | |
:only => [:index, :show, :new, :create, :update, :destroy] | |
private | |
def blogpost_find | |
@blogpost = Blogpost.find(params[:blogpost_id]) | |
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
class CommentsController < ApplicationController | |
before_filter :blogpost_find | |
private | |
def blogpost_find | |
@blogpost = Blogpost.find(params[:blogpost_id]) | |
end | |
def index |
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
{ | |
float: right; | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
top: 0; | |
font-family: Verdana; | |
font-size: 12px; | |
} |
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 Person < ActiveRecord::Base | |
def self.find_recent | |
people = find( | |
:conditions => ["added_at > ? and deleted = ?", Time.now.utc, false], | |
:order => "last_name, first_name") | |
people.reject { |p| p.address.nil? } | |
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
<% form_for(@blogpost) do |f| %> | |
<%= f.error_messages %> | |
<p> | |
<%= f.label :subject %> <br /> | |
<%= f.text_field :subject %> | |
</p> | |
<p> | |
<%= f.label :content %> <br /> | |
<%= f.text_area :content %> | |
</p> |
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
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.1/lib/action_controller/record_identifier.rb:76:in `dom_id' | |
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.1/lib/action_view/helpers/record_identification_helper.rb:16:in `dom_id' | |
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.1/lib/action_view/helpers/form_helper.rb:293:in `apply_form_for_options!' | |
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.1/lib/action_view/helpers/form_helper.rb:277:in `form_for' | |
/Users/seivan/Desktop/Portfolio/app/views/blogposts/_form.html.erb:1:in `_run_erb_app47views47blogposts47_form46html46erb_locals_form_object' | |
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.1/lib/action_view/renderable.rb:36:in `send' | |
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.1/lib/action_view/renderable.rb:36:in `render' | |
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.1/lib/action_view/renderable_partial.rb:20:in `render' | |
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.1/lib/action_controller/benchmarking.rb:26:in `benchmark' | |
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.1/lib/active_support/ |
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
respond_to do |format| | |
format.html | |
format.xml { render :xml => @blogpost } | |
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
#Why can't I have :new there as well? It works when I got the respond_to in def new, but when using before filter, I get | |
#Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id | |
before_filter :respond_to_id, :only => [:show, :new, :update] | |
def respond_to_id | |
respond_to do |format| | |
format.html | |
format.xml { render :xml => @blogpost } | |
end | |
end |