Created
May 22, 2012 06:41
-
-
Save dnagir/2767124 to your computer and use it in GitHub Desktop.
Raptor in Rails?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
def create | |
@article = Article.find(params[:article_id]) | |
@comment = @article.comments.build(params[:comment]) | |
@comment.save # etc | |
end | |
end | |
# I simply want this | |
class CommentsController < ApplicationController | |
def create(article, comment) | |
comment.article = article | |
comment.save # etc | |
end | |
end | |
# Maybe Raptor + Rails can do it? |
Do you think this is really fighting Rails?
It already has a hook just for that.
I'm pretty sure Rails likes fighting... ;)
I don't know; I have little experience with this myself. But the idea of trying to hook into ActionController::Base makes me tired.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could theoretically use Raptor's injector in a controller base class that your controllers inherit from. But fighting Rails is usually a bad idea...