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 User < ActiveRecord::Base; end; | |
class Post < ActiveRecord::Base; end; | |
class Comment < ActiveRecord::Base; end; | |
class AuthorSerializer < ActiveModel::Serializer | |
attributes :id, :name :created_at, :updated_at | |
end | |
class PostSerializer < ActiveModel::Serializer | |
attributes :id, :body :created_at, :updated_at |
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
# encoding: utf-8 | |
class AlbumForm < BaseForm | |
has_many :songs, class_name: 'SongForm' | |
validates :songs, form_collection: true | |
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 FacebookCommentNotifer | |
def initialize(comment) | |
@comment = comment | |
end | |
def save | |
@comment.save && post_to_wall | |
end | |
private |
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
# Beginning Rubyists: simply run >> ruby hex-convertions.rb to see examples | |
# or use irb to build the code on the fly | |
# you can convert HEX to DEC using the method .to_i(base), | |
# which converts a string to a decimal number from the specified base number | |
puts "00".to_i(16) | |
puts "FF".to_i(16) |
NewerOlder