vinsol / fullcalendar-rails-engine

Rails engine implementation of fullcalendar jQuery plugin(http://arshaw.com/fullcalendar/). Create, edit, delete, reschedule, resize events like google calendar.
http://vinsol.com/fullcalendar-demo
MIT License
66 stars 51 forks source link

relationship between user and event #12

Open lymecca opened 10 years ago

lymecca commented 10 years ago

First I have to say my English is poor so apologize if I didn't make myself clear.

I think that it's a great gem! I wan't use it but I need some help about relationship. How can I configure that for events belongs_to user? Is it possible to do something like this...

mount FullcalendarEngine::Engine => "users/user_id/fullcalendar_engine"

and configure model and controller with this relationship?

bansalakhil commented 10 years ago

Hi @lymecca,

We are looking for any possibility to achieve this, will get back to you soon

echan00 commented 10 years ago

Same here.. it would be great if there is a way to have a user per event, and also a calender per user.

For example, teachers who each have a calendar. And then students who can have one or many events with different teachers

asadmoosa commented 9 years ago

That is what I am looking for! Anyone has completed that yet?

felipegruoso commented 9 years ago

Hello,

I did it using devise gem that handles user authentication. But your case looks a little different... You may try something like this:

mount FullcalendarEngine::Engine => "users/:user_id/fullcalendar_engine"

Adds a migration:

rails g migration AddUserToFullcalentarEngineEvents user:references

On your User's model add this:

has_many :events, class_name: "::FullcalendarEngine::Event", foreign_key: "user_id", dependent: :destroy

Then you can use "decorator pattern" to override your engine controller.

EDIT: To override the views you can take a look at this

NOTE: When overriding views, it is necessary to add a file lib/fulcalendar_engine.rb containing the following lines:

module FullcalendarEngine

  class Engine
  end

end

I hope it helps :)

asadmoosa commented 9 years ago

Felipe Gruoso, That is awesome, but i am not sure to understand about "mounting" thing. Where to add "mount FullCalendarEngine...." to which file?

ehannes commented 9 years ago

In config/routes.rb. I have something like this:

  mount FullcalendarEngine::Engine => "/calendar"
  get '/calendar' => 'calendar#index'
asadmoosa commented 9 years ago

So, add mount FullcalendarEngine::Engine => "users/:user_id/fullcalendar_engine" to this. Like

mount FullcalendarEngine::Engine => "/calendar" mount FullcalendarEngine::Engine => "users/:user_id/fullcalendar_engine" get '/calendar' => 'calendar#index'

Right?

ehannes commented 9 years ago

I'm not sure how to handle this if you have several calendars in your app. Maybe the developers of this gem needs to answer that question?

asadmoosa commented 9 years ago

yeah. :(

asadmoosa commented 9 years ago

Tried to do what you asked.

Added the mount of full calendar engine, but not calendar since we can't have two mount paths.

Tested localhost:3000/users/10/fullcalendar_engine. And can't save any event at all. :(