Skip to content

Instantly share code, notes, and snippets.

@dnagir
Created May 22, 2012 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnagir/2767124 to your computer and use it in GitHub Desktop.
Save dnagir/2767124 to your computer and use it in GitHub Desktop.
Raptor in Rails?
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?
@garybernhardt
Copy link

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...

@dnagir
Copy link
Author

dnagir commented May 22, 2012

Do you think this is really fighting Rails?

It already has a hook just for that.

@garybernhardt
Copy link

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