invisiblefunnel / view_accessor

An alternative method of sharing state between Rails controllers and views.
MIT License
1 stars 0 forks source link

Thinking about setters #1

Open Odaeus opened 11 years ago

Odaeus commented 11 years ago

Hi Danny,

I just found your comment on the gist about this today. I'm very happy that I've inspired some experimentation!

Your implementation looks good. The main thing I would think about is whether you actually want to use helper_method on setters. In theory this would allow you to assign the variable in the view, which is something you would want to avoid I think? Also I think the hide_action on the setter will have no effect as I wouldn't hope Rails would not let you call it as an action, but I haven't tested this!

Thanks, Andrew

invisiblefunnel commented 11 years ago

Hi Andrew,

Thanks for taking a look!

I wondered whether to expose the setters to the view also. In the end I decided to use helper_method on setters because it seemed like the least surprising behavior. That said, I like the idea of injecting a little opinion into the implementation.

Using hide_action on the setters seemed like the most complete solution. I'm not sure if it has a real effect or not, outside of this private method in ActionController::Base.

I'll add you as a collaborator. Please make any changes you see fit. It would be fun to release this and see what people think.

Best, Danny