Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return json from controller for upcoming backbone integration #37

Open
phansch opened this issue Feb 24, 2014 · 3 comments
Open

Return json from controller for upcoming backbone integration #37

phansch opened this issue Feb 24, 2014 · 3 comments
Assignees

Comments

@phansch
Copy link
Contributor

phansch commented Feb 24, 2014

No description provided.

@mamhoff
Copy link
Contributor

mamhoff commented Mar 12, 2014

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
Copy link
Contributor Author

phansch commented Mar 12, 2014

@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
Copy link
Contributor

mamhoff commented Mar 12, 2014

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" [email protected]:

@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//issues/37#issuecomment-37395758
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants