-
Notifications
You must be signed in to change notification settings - Fork 212
Quickstart from scratch
Create a new rails project, display a calendar, and optionally create some events.
(This is using Rails 3 and SQLite. If using RVM you may need to install the Rails gems first.)
- rails new cal_test
- cd cal_test
- gem install event-calendar
- Add to Gemfile: gem 'event-calendar', :require => 'event_calendar'
- rails generate event_calendar
- rake db:migrate
- rails server
Hooray! A calendar should now be running at http://localhost:3000/calendar
In your view or layout you'll probably want to include the generated javascript:
<%= javascript_include_tag 'event_calendar' %>
(The stylesheet should be included by the stylesheet_link_tag :all method in the layout.)
The plugin is only concerned with displaying 'event' objects that at a minimum have start_at and end_at fields. The generator created some helpful MVC code to get you started, but leaves creating/editing/deleting events up to you. Let's use the Rails scaffold generator to get some basic event management up and running.
- For expediency, let's remove the migration the event_calendar generator created. This will let us run the following scaffold. (We could have just run this before the event_calendar generator in the 'Bring up a calendar' steps.)
- Run the scaffold:
rails generate scaffold Event name:string start_at:datetime end_at:datetime
(No need to overwrite the event.rb model.) 3. Make sure to have those two lines in your event.rb
attr_accessible :end_at, :name, :start_at
has_event_calendar
- Now we can manage events at http://localhost:3000/events
- Create an event or two and return to http://localhost:3000/calendar to view them.
- Remove or modify scaffold.css in public/stylesheets as it changes the color of hovered links.
Hooray! Now we have a calendar displaying some events.