i've a problem
i'm trying to make an action method like this
def webm
#url = Video.find(params[:id]).avatar.url(:webm_sd)
end
and i just want to return the #url value without using view .. it will return string url i need it to be rendered where ever the method get called
it gives me error
Missing template api/v1/videos/webm, application/webm with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
and even if i add some views in videos folder it still gives me the same error!
what should i do?
You can use proper renderer
render json: #url
or to render just string
render text: #url
Related
I am having a problem with a Ruby on Rails app running on Heroku. The method set_default_activities of activities controller ends on
redirect_to root_path
but it appears to be looking for a view template called "activities/set_default_activities":
2016-06-23T04:15:39.021209 #3] FATAL -- :
2016-06-23T04:15:39.021744+00:00 app[web.1]: ActionView::MissingTemplate (Missing template activities/set_default_activities, application/set_default_activities with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder]}.
I have read the previous posts on this error and they appeared to suggest adding the line
render nothing: true
I have done this on the second-to-last line but the problem persists. What should I try next?
In your activities controller, modify the redirect line to:
redirect_to root_path and return
I have a rails app running on passenger with a mailer. I have it so the page following the action shows the email content but I get this error:
Missing template rfis/mail, application/mail with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :slim, :jbuilder]}. Searched in: * "/var/www/rqm3/app/views" * "/usr/local/rvm/gems/ruby-2.1.5/gems/devise-3.5.1/app/views" * "/usr/local/rvm/gems/ruby-2.1.5/gems/twitter-bootstrap-rails-3.2.0/app/views"
despite this, the email does correctly load the template when being sent. It's only showing it in a view that causes issues.
rfis_controller.rb:
def mail
#mail_message = RfiMailer.send_rfi(current_user, #rfi).deliver
end
rfi_mailer.rb:
class RfiMailer < ApplicationMailer
default from:"testemail#mail.com"
def send_rfi(user, rfi)
mail(to:"other#test.com")
end
end
send_rfi.html.erb:
test
Issue is due to you are not redirecting anything inside your method "mail" define inside controller
def mail
#mail_message = RfiMailer.send_rfi(current_user, #rfi).deliver
redirect_to #user, notice: "Message sent successfully ."
end
you can also define render nothing
I have a view with the following format:
show_map.html+phone.slim
I am testing my controller, expecting my test to render that template , does anyone know the proper syntax for rendering a view with variant ?
This is what I am trying:
describe "show_map action" do
it "renders show map view" do
get :show_map, {:id=>#job.id,:format=>:html,:variants=>:phone}
expect(response).to render_template('show_map')
end
also tried
get :show_map, {:id=>#job.id,:format=>'html.phone'}
Either way, I get a missing template error:
JobsController show_map action renders show map view
Failure/Error: get :show_map, {:id=>#job.id,:format=>:html,:variants=>:phone}
ActionView::MissingTemplate:
Missing template jobs/show_map, application/show_map with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :slim]}
Anyone know how to do this?
This should be pretty simple, trying to render a partial on active admin in show action:
Object name is: Listing
ActiveAdmin.register Listing do
show do
attributes_table do
row :foo
row :bar
render 'map'
end
end
end
I added the partial under app/admin/listings/_map.html.haml
I get the no template found error:
Missing partial admin/listings/_map, active_admin/resource/_map, active_admin/base/_map, inherited_resources/base/_map, application/_map with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :haml, :jbuilder]}.
Also tried adding here: app/admin/_map.html.haml and admin/listings/_map.html.haml
And tried: moving the render outside the attributes_table, like so:
show do
render 'map'
attributes_table do
row :foo
row :bar
...
On rails', '4.1.9', 'activeadmin', '~> 1.0.0.pre1'
Your view should be put into views directory:
app/views/admin/listings/_map.html.haml
Rendering partial should look as follows:
show do
render partial: 'map'
# ...
end
I'm attempting to use a jbuilder template.
Given the controller,
class Api::ReviewsController < ApplicationController
before_filter :authenticate_user!
respond_to :json
def create
#review_request = ReviewRequest.new(review_request_params.merge(user_id: current_user.id))
if #review_request.save
render 'review_requests/review'
else
head :forbidden
end
end
end
and I have the jbuilder template stored at app/views/review_requests/review.json.jbuilder
json.review_request do
json.(#review_request, :title,)
end
I'm getting a template note found error.
ActionView::MissingTemplate (Missing template review_requests/review with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
* "/Users/jd/Dropbox/application-code/antipattern/app/views"
* "/Users/jd/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/devise-3.4.1/app/views"
* "/Users/jd/Dropbox/application-code/antipattern"
* "/"
):
app/controllers/api/reviews_controller.rb:8:in `create'
Any thoughts on either where the correct place to store this template is or why rails isn't finding the template i'm using (if the storage location happens to be ok)?
jbuilder needs a json type web request, an html request to a rails server will cause the jbuilder template to not be rendered.