Created
January 30, 2012 18:31
-
-
Save coderforhire/1705842 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Event < ActiveRecord::Base | |
has_event_calendar | |
belongs_to :user | |
end | |
class User < ActiveRecord::Base | |
# Include default devise modules. Others available are: | |
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable | |
# Setup accessible (or protected) attributes for your model | |
attr_accessible :email, :password, :password_confirmation, :remember_me | |
has_many :events | |
end | |
class CreateEvents < ActiveRecord::Migration | |
def self.up | |
create_table :events do |t| | |
t.string :name | |
t.datetime :start_at | |
t.datetime :end_at | |
t.timestamps | |
end | |
end | |
def self.down | |
drop_table :events | |
end | |
end | |
class AddUserIdToEvents < ActiveRecord::Migration | |
def change | |
add_column :events, :user_id, :integer | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cat app/views/events/new.html.erb
New event
<%= render 'form' %>
<%= link_to 'Back', events_path %>
afresta@afresta:~/rails_projects/YC_dev$ cat app/views/events/_form.html.erb
<%= form_for(@event) do |f| %>
<% if @event.errors.any? %>
<%= pluralize(@event.errors.count, "error") %> prohibited this event from being saved:
<% end %>
<%= f.text_field :name %>
<%= f.text_field :start_at %>