I just installed the gem "chartkick" to my gemfile and copyied and pasted some code just to get the project started, this is what I used in my view.
<%= pie_chart({"Football" => 10, "Basketball" => 5}) %>
I also included
<%= javascript_include_tag "path/to/highcharts.js", "chartkick" %>
So that is not the issue but I keep getting this error
Any ideas on what I'm doing wrong?
Try this, After installing the "chartkick" gem,
replace this javascript include tag
<%= javascript_include_tag "path/to/highcharts.js", "chartkick" %>
with this
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
Related
I have tried with gem datepicker, but i have to use datepicker without any gem of datepicker?
i have added datepicker js files like
bootstrap-datepicker.ja.js
bootstrap-datepicker.js
this file i have loaded in view(erb)
<%= javascript_include_tag 'locales/bootstrap-datepicker.ja.js', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'bootstrap-datepicker.js', 'data-turbolinks-track' => true %>
but it's not working giving error like
in console:
ActionView::Template::Error (bootstrap-datepicker.js):
error on page:
Sprockets::Rails::Helper::AssetNotPrecompiled in MUser#index
bootstrap-datepicker.js
Check if you have jquery included, otherwise you cannot use bootstrap.
try adding <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> in your view above the other two scripts.
So your code should look something like this:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<%= javascript_include_tag 'locales/bootstrap-datepicker.ja.js', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'bootstrap-datepicker.js', 'data-turbolinks-track' => true %>
You could also have a look at <%= form.date_field :date_attribute %> - it will use a native date picker, supported by all major browsers.
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
<%= form.date_field :date, attribute: 'date' %>
where the :date is your model
I realize that this has been asked on here before, but I don't seem to have the same issue as the previous person as the solutions provided had no effect.
My error is a little different as well.
undefined method `bootstrap_form_for' for #<#<Class:0x007fd2b0c2dbe0>:0x007fd2b0c2c948>
The code that references the method:
<%= bootstrap_form_for(#blob) do |f| %>
<%= f.text_field :contentType %>
<%= f.text_field :data %>
<%= f.text_field :form_id %>
<%= f.submit "Create BLOB" %>
<% end %>
The method comes from this gem.
The gem is in the Gemfile, I have restarted the rails server a few times, and I've tried this with multiple models.
It seems like bundle install was automatically fetching version 3.0.0 of the Gem, but the GitHub lists 2.3.0 as the most recent version available.
Switching to 2.3.0 in my Gemfile fixed the issue.
I have added the bootstrap-sass gem and have installed the bundle. I have gone to github and think I have followed the directions correctly to finish the install for ruby on rails. It doesn't appear to be making a difference however on my local site - no font/formatting changes have been made, even after the install.
I am using a PC, https://github.com/findingtheway/pin
Change your app/views/layouts/application.html.erb to this:
<head>
<title>Pin</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
Rails uses application by default you have default which is why bootstrap is not loading.
Whenever I try to upload a file with Carrierwave + s3 on my Heroku app I get this error "We're sorry, but something went wrong.", looking into my log I see this error:
2012-08-20T21:18:56+00:00 app[web.1]: Started GET "/assets/" for 24.90.124.181 at 2012-08-20 21:18:56 +00002012-08-20T21:18:56+00:00 app[web.1]:2012-08-20T21:18:56+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets"):
I've did everything in this tutorial to deploy my app to Heroku on the Cedar stack, but I still see that error. I also had to add this to my application.html
<%= javascript_include_tag :defaults %> <%= javascript_include_tag "jquery" %> <%= javascript_include_tag "nested_form"%> <%= javascript_include_tag "application"%>
because having <%= javascript_include_tag "application" %> only loaded "application.js"
I've tried everything I come across trying to get my uploader to work, but I don't know what the problem is. Everything works perfectly on my local app.
This is my app on github
My Heroku app
you can easyly replace the
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag "jquery" %>
<%= javascript_include_tag "nested_form"%>
<%= javascript_include_tag "application"%>
with: <%= javascript_include_tag "application" %> if your application.js file do this imports.
the default imports are:
//= require jquery
//= require jquery_ujs
//= require_tree .
if the problem is a missing javascript this should fix it
Other problem i see was this link inside app/views/deals/show.html.erb:
<%= image_tag(#deal.user.logo, :class => 'company_logo') %>
this line is returning this html:
<img alt="Assets" class="company_logo" src="/assets/">
this img src is invalid, and that is the error your are receiving on log.
if this image tag could link to an image path, like /assets/avatar.png i believe your problem will be fixed
Since you are using Carrierwave, you need to do the following:
<%= image_tag(#deal.user.logo.url, :class => 'company_logo') %>
or
<%= image_tag(#deal.user.logo.current_path, :class => 'company_logo') %>
I'm using Rails 3 and have have a page that outputs a list of posts from the database. I'd like to be able to delete a post from a link.
The 2nd example below works, but the first doesn't. Anybody know why the first won't work? My view contains:
# this link sends a "GET" request which asks for the #show function
<%= link_to 'Delete', post, :method => :delete %>
# this link sends the proper "DELETE" request which asks for the #destroy function
<%= button_to 'Delete', post, :method => :delete %>
My routes file contains the following:
resources :posts
Make sure that your <head> section in the layout includes the following:
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
In Rails 3, the delete requests are being handled with the help of JavaScript to ensure that the request is being sent correctly. If you don't have the csrf meta tags and the required JavaScript code, delete links won't work. The :defaults JavaScript files include--among others--prototype.js, and application.js. The latter contains the stuff that makes the link work, but relies on the Prototype framework.
If you don't want to use the default Prototype JavaScript libraries, there are ports of application.js for several other frameworks. You can find the jQuery one here, for instance.
Buttons will still work regardless of JavaScript, as the HTML code generated with button_to includes all necessary information by itself. This is why you're seeing the button work while the link doesn't.
looks like
<%= javascript_include_tag :defaults %>
is no longer supported
http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/JavascriptTagHelpers/javascript_include_tag
Instead, you should use
<%= javascript_include_tag 'application' %>
I had the same problem in rails 5.2.3 and this helped me:
layout head:
<%= javascript_include_tag "rails-ujs" %>
config/initializers/assets
Rails.application.config.assets.precompile += %w( rails-ujs.js )
In my case, I was using following.
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
I was also using jQuery by including jQuery just below default prototype JS. That was causing some sort of conflict.
Destructive actions should be performed as a form submission - http://www.w3.org/2001/tag/doc/whenToUseGet.html#checklist
You can style the button appropriately for delete method or Use Form.
I had the same issue in Rails 6.
The solution by Romalex to include:
<%= javascript_include_tag "rails-ujs" %> in head tag &
Rails.application.config.assets.precompile += %w( rails-ujs.js ) in config/initializers/assets also worked to solve an issue with destroy_user_session in devise which would not DELETE.
So this solution also applies to this question Ruby on Rails - devise users/sign_out not working
This will work. The issue is the fact that you need to pass it the right path so the route gets it.
<%= link_to 'Delete', post_path(post.id), :method => :delete %>
In my case with Rails 5, I was using following in my layout:
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
In this way:
... </title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
...
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
Try this.. its a simple change..
add this to your route.rb file
get '/lists/:list_id/comments/:id' => 'comments#destroy'
I made this change and now its working..
In my case.....
In head:
<%= csrf_meta_tag %>
In config/initializers/assets.rb:
<%= javascript_include_tag :defaults %>
Was the answer! Great call!