defself.tagged_with(name) #name is an array of 1 or more tag names
all(:conditions => {:tags => {:name => name}},
:joins => :taggings,
:joins => :tags,
:group => 'articles.id',
:having => ['COUNT(*) >= ?', name.length]
)
end
After some exploration, actually you can still use the url_helpers such as edit_product_path etc by just including the rails url_helper in your class e.g.
ruby
classYourDatatable
include Rails.application.routes.url_helpers
.
.
def data
.
link_to("edit", edit_product_path(product)
endend
It seems this episode won't work for me.
I'm having errors:
LoadError in Products#index
Showing /home/askar/work/rails_studio/store/app/views/layouts/application.html.erb where line #5 raised:
cannot load such file -- less
(in /home/askar/work/rails_studio/store/app/assets/stylesheets/bootstrap_and_overrides.css.less)
Extracted source (around line #5):
Question! I am trying to eliminate the use of regular model IDs to access my pages. IE, right now, you can still go events/1, as opposed to just the custom (for me it's a hash) such as events/12k5s
I want to eliminate any possible guessing of other pages. How would I eliminate the old option?
Does anyone know why has rails not adopted EventMachine? When i google around, i am unable to find any good concrete examples of usage of EM with Rails3.2. Would we have any out of the box compatibility from Rails4 for EM?
My nginx.conf is OK and nginx seems to start but my https URL in Google Chrome gives me an this error:
SSL connection error
Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have.
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.
I have an issue with this when im deploying my app to heroku, the vestal_versions gem works great locally but not on heroku. It seems that the versions are not working and my records are not being updated when I edit a post.
I know this is an old episode but I wanted to clarify the path used for the pid. In the config/mailit.god file in the God.watch block you have this path for the pid:
ruby
w.pid_file = "#{RAILS_ROOT}/log/workling.pid"
Is not the convention for pids to be put in the tmp folder? Like this:
I have a problem with nested forms and a polymorphic model. Using comments as an example, how does one add multiple has_many :through for the comments needed.
Example:
My next polymorphic task is to add this exact function to a small app I have. I thought I was starting easier to just have an address field shared across models but there's not much out there to help with that, especially for Rails 4. I have put together how I got an address polymorphic association working in my app at my blog if anyone needs that help.
def self.open_spreadsheet(file)
case File.extname(file.original_filename)
when ".csv" then Roo::Csv.new(file.path, nil, :ignore)
when ".xls" then Roo::Excel.new(file.path, nil, :ignore)
when ".xlsx" then Roo::Excelx.new(file.path, nil, :ignore)
else raise "Unknown file type: #{file.original_filename}"
end
end
you are populating the statistics_chart div with data from data-statistics attribute of that div, look in inspect element and you'll see the html5 attribute called data-statistics with an array of hashes inside.
I followed this RailsCast tutorial, then later discovered csv_builder. Like you said, the template/view approach is much better! I think this RailsCast should be revised to use csv_builder rather than putting CSV view logic in the Controller as it recommends!
2013blahblahblahfoo000 is basically a timestamp with milliseconds so even repeating the action immediately after the first action the value/cache_key cannot be the same.
I was hoping you could weigh in here, I'd like to create a rubber capistrano recipe to deploy my rails app using nginx and phusion passenger enterprise edition. The main problem I have is changing the rubber tasks to install the passenger gem from a local file instead of from the open-source repo. If you could please provide some guidance I would be very appreciative.
Here is the solution for those who may want it:
Adding:
*= require bootstrap_and_overrides
to the applications.css solved.
Stackoverlow
thank you : it worked here too :
def self.tokens(query)
filter_query = query.gsub(/[^a-zA-Z&\s]/, '')
filter_query = filter_query.strip
topics = where("LOWER(name) like ?", "%# {filter_query.downcase}%")
topics << {id: "<<<#{query}>>>", name: "New: \"##{filter_query}\""}
end
After some exploration, actually you can still use the url_helpers such as edit_product_path etc by just including the rails url_helper in your class e.g.
Hi Ryan! Thanks for the challenge! It sounds really cool :) +1
Can anybody point me for which environment does this episode work for? Is it written somewhere?
I'm using Rails 4.0.0.rc1 and ruby 1.9.3p392.
It seems this episode won't work for me.
I'm having errors:
LoadError in Products#index
Showing /home/askar/work/rails_studio/store/app/views/layouts/application.html.erb where line #5 raised:
cannot load such file -- less
(in /home/askar/work/rails_studio/store/app/assets/stylesheets/bootstrap_and_overrides.css.less)
Extracted source (around line #5):
2
3
4 Store
5 <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6 <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7 <%= csrf_meta_tags %>
8
Rails.root: /home/askar/work/rails_studio/store
Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__3286420188203285275_35132680'
Question! I am trying to eliminate the use of regular model IDs to access my pages. IE, right now, you can still go events/1, as opposed to just the custom (for me it's a hash) such as events/12k5s
I want to eliminate any possible guessing of other pages. How would I eliminate the old option?
I wonder why Ryan's code doesn't include them in Gemfile...
Mauricio,
I have an existing rails app that uses devise and I want to connect to it using backbone.js from another app.
Were you able to obtain any feedback as to the best way to go about this?
Kind regards
Andrew
Hi Ryan!
Any plans to revise this with Rails 4 ?
Hey anso,
Use the normal link_to :
Ever figure this one out TopperH? I've been struggling with the same problem.
I don't know how to get the link of an image I upload in a page, with a data-mercury="image".
For example, i have this:
<div> id="page_content" data_mercury="full"></div>
I get it in the controller like this:
params[:content][:page_title][:value]
How to do with ?:
<img id="article_image" data-mercury="image">
Thank you
May be you should convert ActionDispath to Array or String.
Search and tags will give you more suggestion.
+1
Does anyone know why has rails not adopted EventMachine? When i google around, i am unable to find any good concrete examples of usage of EM with Rails3.2. Would we have any out of the box compatibility from Rails4 for EM?
My nginx.conf is OK and nginx seems to start but my https URL in Google Chrome gives me an this error:
SSL connection error
Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have.
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.
When I do a
lsof -i:443
I see this:Do I have other crap listening on 443?
I have an issue with this when im deploying my app to heroku, the vestal_versions gem works great locally but not on heroku. It seems that the versions are not working and my records are not being updated when I edit a post.
Anyone know whats going on?
Thanks, Vincent.
Same here. I'll post if I figure something out.
I know this is an old episode but I wanted to clarify the path used for the pid. In the config/mailit.god file in the God.watch block you have this path for the pid:
w.pid_file = "#{RAILS_ROOT}/log/workling.pid"
Is not the convention for pids to be put in the tmp folder? Like this:
w.pid_file = "#{RAILS_ROOT}/tmp/workling.pid"
Hope you can reply...
How do I allow a non technical user to change a products order form?
like add products, and change prices?
If you are using Paginate/kaminari with Sunspot use this code with in the index in the Controller.
Never mind, must have been too little sleep. Using a class_name solves it.
I have a problem with nested forms and a polymorphic model. Using comments as an example, how does one add multiple has_many :through for the comments needed.
Example:
has_many :comments, :through => :images
has_many :comments, :through => :articles
The second has_many overwrites the first one and :through only allows one reference.
Any tips appreciated.
Hi Ryan, thx for this great episode !
One question:
How could i make paperclip to work with your tutorial ?
Thx !
Do you have this in your class? table-striped
I suggest you look at your Rails console to see if there is a message showing an error. It's likely a data read error.
The following puts each record into a dataTable cell instead of a row:
Any way to fix?
My next polymorphic task is to add this exact function to a small app I have. I thought I was starting easier to just have an address field shared across models but there's not much out there to help with that, especially for Rails 4. I have put together how I got an address polymorphic association working in my app at my blog if anyone needs that help.
http://hamcois.com/articles/6
I do this with Redis using redis-objects: https://github.com/nateware/redis-objects
Another option is X-editable. It offers similar functionality, but uses Bootstrap/JqueryUI/Jquery elements. Really works fantastic in my Bootstrap UI.
ActiveAdmin helped us get up and running quickly, but once we had use cases outside of very simple CRUD, it became nightmarish.
Do read this: http://staal.io/blog/2013/02/26/mastering-activeadmin/
I did try rails_admin first because it seemed more customizable but it didn't have all the features I wanted
Add these gems to your Gemfile:
gem "therubyracer"
gem "less-rails"
You're supposed to override the _id field:
Docs: http://mongoid.org/en/mongoid/docs/upgrading.html
Still no chance?
No one has the same problem?
correction with open_spreadsheet method
def self.open_spreadsheet(file)
case File.extname(file.original_filename)
when ".csv" then Roo::Csv.new(file.path, nil, :ignore)
when ".xls" then Roo::Excel.new(file.path, nil, :ignore)
when ".xlsx" then Roo::Excelx.new(file.path, nil, :ignore)
else raise "Unknown file type: #{file.original_filename}"
end
end
Did you solve this issue? I've having the same problem.
Were you able to solve this issue? I'm running into the same problem.
I know this is 6 months old, but:
You'll want to handle this in your routes.rb file.
Something like:
get ":id" => 'users#show', as: :name_your_path
you are populating the statistics_chart div with data from data-statistics attribute of that div, look in inspect element and you'll see the html5 attribute called data-statistics with an array of hashes inside.
very handy, thank you :)
I followed this RailsCast tutorial, then later discovered csv_builder. Like you said, the template/view approach is much better! I think this RailsCast should be revised to use csv_builder rather than putting CSV view logic in the Controller as it recommends!
Note new repo URL: https://github.com/gtd/csv_builder
Is there any way to update attributes for miltiple objects with nested form?
I used this code in controller:
It is similar to example
But instead of updating the records, Ruby creates new ones and nullifies "work_id" in existing records.
What could cause this problem? Thank you!
+1
2013blahblahblahfoo000 is basically a timestamp with milliseconds so even repeating the action immediately after the first action the value/cache_key cannot be the same.
I have created a list of gems for Development Machine in Ruby on Rails to make to your development life much more easier/productive
Hi Ryan,
I was hoping you could weigh in here, I'd like to create a rubber capistrano recipe to deploy my rails app using nginx and phusion passenger enterprise edition. The main problem I have is changing the rubber tasks to install the passenger gem from a local file instead of from the open-source repo. If you could please provide some guidance I would be very appreciative.
+1