BiteKollektiv / webcal

Anonymous web calendars as a service
GNU General Public License v3.0
2 stars 1 forks source link

Return json from controller for upcoming backbone integration #37

Open phansch opened 10 years ago

mamhoff commented 10 years ago

There's now json actions for calendar#show and events#show. However, it still barfs when the wrong token is specified (rather than returning 404).

Right now, the json returns are implemented using to_json, which is sorta fine, but doesn't allow for a lot of control over how the json is serialized and (in my opinion) mixes view and controller stuff into one magic railsy thing.

phansch commented 10 years ago

@mamhoff To limit the returned data, I think you can use something like to_json(only: [:title, ...]). Take a look here.

In terms of view/controller separation, as long as you just return json, I think it should be in the controller. The view is just used for presenting data to a user. In our case the presentation would be handled by a backbone template.

Not sure about the token issue

mamhoff commented 10 years ago

Yeah, I know. The before filter works great actually if you have valid data, but barfs if your hash is invalid. Am 12.03.2014 11:53 schrieb "Philipp Hansch" notifications@github.com:

@mamhoff https://github.com/mamhoff To limit the returned data, I think you can use something like to_json(only: [:title, ...]). Take a look herehttp://apidock.com/rails/ActiveRecord/Serialization/to_json. In terms of view/controller separation, as long as you just return json, I thinkt should be in the controller. The view is just used for presenting data to a user. In our case the presentation would be handled by a backbone template.

Not sure about the token issue

Reply to this email directly or view it on GitHubhttps://github.com/BatchZero/webcal/issues/37#issuecomment-37395758 .