Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mumoshu/aae19afee1db4467e059 to your computer and use it in GitHub Desktop.

Select an option

Save mumoshu/aae19afee1db4467e059 to your computer and use it in GitHub Desktop.
ActionView・Partial TemplatesをRails Consoleでテストする方法
Rails.application.routes.default_url_options = { :host => 'example.com' }
view_paths = Rails.application.config.paths["app/views"]
action_view = ActionView::Base.new(view_paths).tap do |av|
action_view.class_eval do
include ApplicationHelper
include Rails.application.routes.url_helpers
include JobOffersHelper
end
end; nil
action_view.render partial: 'default/job_offer', locals: { job_offer: JobOffer.first }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment