RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Getting an error on this line (in the coffeescript file)

puts " if ($('.pagination').length) {"

The error message says: Uncaught TypeError: Cannot read property 'length' of null

What could have gone wrong? The div exists in my index :(

Avatar

I had problems with the encoding of my mysql database, so here is the trick:

taps server mysql://root@localhost/example_database?encoding=UTF8 httpuser httppassword

From: https://github.com/ricardochimal/taps/issues/110#issuecomment-6364498

Avatar

Làm ăn như khỉ ,

$ rails generate devise_install sai cmnr , đúng là phải viết

$ rails generate devise:install

ngu vkl.

Avatar

meta_request just immediately blows up with stack too deep errors for me, but I don't get any kind of stack request at all to try to understand where it's happening. :/

Avatar

include in your gemfile
gem 'omniauth-twitter'

Avatar

rails g migration add_rpx_to_users rpx_identifier:string
gives an error. It says that there is no such file to load.

Avatar

For any new users reading this post, the .live() method was removed on JQuery 1.9, you can use the on() method instead.

Avatar

I get this error when i try to run the specs:

console
Exception encountered: #<LoadError: cannot load such file -- capybara/poltergeist>
backtrace:

What could that be for?

Avatar

did you figure this out? Just got the same problem

Avatar

This episode will not work in the current Rails 3.2.11 and devise 2.2.3. (January2013). So see the video in the following link. It works correctly.
http://www.slideshare.net/wleeper/devise-and-rails

Also run 'rake db:migrate' in the terminal.

Avatar

After import I need to populate one of the columns with the foreign key so that I can associate each row uploaded from the file with the user that uploaded it. However, the foreign key (restuarant_id) is stored in a session when the user logs in. seeing that I can't or should't access sessions in the model, how do I accomplish this?

Avatar

Do you mean that it adds the same data in the file again instead of updating? If so, Change the find_by in the model to another field instead of id. For me, I use first name & last name seeing as this would not be one of the changes made to the uploaded file.

Avatar

Hi Ryan :

I am using the source code for "Gallery After" folder. When I upload Image , the Images are getting uploaded to S3 bucket. But while displaying all the uploaded images, I am getting "Processing..." rather than the uploaded image.
What could have gone wrong ?

Avatar

Tried to implement this episode, it works!

Not such a big overhead adding Redis server.

Avatar

Using Hstore would do searching, sorting, filtering you can index with Hstore to be fast

Avatar

Better_errors looks great, but after installing my application would intermittently crash while running my rspec/capybara tests. After removing the gem, things went back to normal. Just a word of warning for others (using rails 3.2.8... yes, yes, I'm about to patch).

Avatar

Turned out it had nothing to do with this RailsCast, please ignore the comment above.

Avatar

I'm using RailsAdmin and got the following error:

NoMethodError in RailsAdmin::MainController#index
undefined method `klass' for nil:NilClass
app/controllers/application_controller.rb:26:in `user_time_zone'

What went wrong?

Avatar

I'm not sure if I'm thinking this through correctly. Would people agree that ProductField names should not be update-able. In the serialized hash the key would remain what it was originally as, so unless the developer goes back and sanitizes all of the product properties in the database, or adds some method_missing translations to the ProductType class a back end client name update would break all of the existing products of that type. Maybe?

Avatar

Hi Ryan,

I signed up on Railcasts today and now i feel like a kid in candy store. Too much of exciting stuff.

However, my excitement is bit tampered...I guess am having difficulty finding the right episodes.

After going through this episode, I am able to get email working but stuck at one place.

my config:

ActionMailer::Base.default_url_options = {host: "localhost:3000"}

works perfectly. But how do I make the host dynamic? I will be using heroku to host multiple domains for the same app. So my hosts will be sub1.mydomain.com, sub2.mydomain.com etc.

If you have already covered this in another episode, can you point me to it please.

Regards,
Murty

Avatar

nice, the smell of the dark side :)
but it's better to avoid this kind of structures because it kills searching, sorting, filtering and other common features... don't you think?

Avatar

I use both pry, but since I switched to pow, it's become a pain. I started using better_errors and now when I'm doing something in the browser where I'd normally use pry, I just throw and use the binding it give you. Far easier. I still use pry for tests and such.

Just my .02.

Avatar

Thanks so much! This was a lifesaver.

Avatar

Getting this error - Please help me

** [out :: production.foo.com]
** [out :: production.foo.com] /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongo-1.3.1/lib/mongo/connection.rb:518:in connect'
** [out :: production.foo.com] :
** [out :: production.foo.com] Failed to connect to a master node at production.foo.com:27017
** [out :: production.foo.com] (
** [out :: production.foo.com] Mongo::ConnectionFailure
** [out :: production.foo.com] )
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongo-1.3.1/lib/mongo/connection.rb:656:in
setup'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongo-1.3.1/lib/mongo/connection.rb:101:in initialize'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongo-1.3.1/lib/mongo/connection.rb:152:in
new'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongo-1.3.1/lib/mongo/connection.rb:152:in from_uri'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid/config/database.rb:89:in
master'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid/config/database.rb:22:in configure'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid/config.rb:273:in
configure_databases'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid/config.rb:94:in from_hash'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid/config.rb:109:in
block in load!'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid/config.rb:108:in tap'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid/config.rb:108:in
load!'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid.rb:147:in load!'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.5/lib/mongoid/railtie.rb:84:in
block in class:Railtie'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:30:in instance_exec'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:30:in
run'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:55:in block in run_initializers'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:54:in
each'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:54:in run_initializers'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/application.rb:96:in
initialize!'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in method_missing'
** [out :: production.foo.com] from /usr/local/graylog2-web-interface-0.9.6p1/config/environment.rb:6:in
'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in require'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in
block in require'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in block in load_dependency'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in
new_constants_in'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in load_dependency'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in
require'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/application.rb:83:in require_environment!'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/commands/runner.rb:40:in
'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/commands.rb:63:in require'
** [out :: production.foo.com] from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/commands.rb:63:in
'
** [out :: production.foo.com] from ./script/rails:6:in require'
** [out :: production.foo.com] from ./script/rails:6:in
'
command finished in 172775ms
failed: "/bin/bash -l -c 'sudo -p '\''sudo password: '\'' bash -l /tmp/bootstrap_graylog_web'" on production.foo.com

Avatar

For information, the app crashes when handling failure scenario provided by stripe. https://stripe.com/docs/testing

Avatar

I do have another issue though where I have other forms on the same page that I am refreshing data and when any of those buttons are pushed I sometime run into a situation where the request is killed. I think I may need to make those form submits into ajax calls as well. Does this sound right? By the way those other forms on the page make actual calls to external services so sometimes it's not instantaneous like it would be if I was using ActiveRecord like in your screencast. Thanks in advance for any help.

Avatar

So it looks like I had two things missing which might help others. First my controller needed a "format.js" in the respond_to. The other is my request was being sent as html, so I had to switch the request to "$.ajax({ url: $('#group-instances').data('url'), dataType: "script" })" where group-instances was my id.

Avatar

Got it working in ruby with ubuntu using gedit as my editor and chrome as browser. I will post the link as soon as I get it up on github.

Avatar

Has anyone got jCrop working with ActiveAdmin? If so, how would you pass the instance variable to the render template?

Avatar

I am working on an app that has all the tenants data in one table. I am looking at segregating that for security reasons. My target market will have a range of security requiremnts - some won't care and will be fine with the shared set-up some would want something like Apartment and some perhaps extreme like a completly separate instance of the app on a subdomain or internally hosted.

Any suggestions on such a set-up? I am thinking I could have a 'basic' plan (shared db), a 'plus' plan (Apartment etc.) and a 'pro' plan (private server type setup). I have no real data but I would say the split would be 75%/20%/5%.

Is it worth the effort to maintain 3 versions of the same code base?

Avatar

Can anyone please reply why rubber commands do not work in eclipse terminal...

I am getting this -
$ rubber vulcanize complete_passenger_postgresql
ERROR: No such sub-command 'vulcanize'

See: 'rubber --help'

Avatar

This is a bit of an older post, and I am new to rails, but I had a problem with this railscast. I had to add this:

accepts_nested_attributes_for :categorizations

to the product model in order to allow me to create a new products with categories. Is this something that is new since this railscast was created?

Avatar

A small sample how to access redmine and post a comment on a ticket as well as a small snippet accessing rm via api-key

ruby
require 'rubygems'
require 'active_resource'

# Issue model on the client side
class Issue < ActiveResource::Base
  self.site = 'http://xyz.x-itec.net/'
  self.user = 'bk'
  self.password = 'bar'
end

issue = Issue.find(111)
issue.notes="Ruby-Dude"
issue.save

-----



require 'rubygems'
require 'active_resource'

# Issue model on the client side
class Issue < ActiveResource::Base
headers['X-Redmine-API-Key'] = '8ab9925cc104ec166e432cf938339ca7bc521e88'

  self.site = 'http://xyz.x-itec.net/'
#  self.user = 'bk'
#  self.password = 'bar'
end

issue = Issue.find(111)
issue.notes="Ruby-Dude API-KEY"
issue.save
Avatar

Just to provide more information I don't see something similar to yours where when on the article page you see a request coming in where it says:

Rendered comments/index.js.erb

Mine says something like:

Rendered environments/index.html.haml within layouts/application (1.2ms)

Avatar

Wow! I feel like I need to watch this several times in slow motion to absorb it. It's amazing how much you can pack into 14 minutes. It also seems like really understanding dynamic forms could simplify my database architecture.

Avatar

Hi Ryan,

Thanks for the great video. I am having an issue where the app/views/comments/index.js.erb isn't being executed for me. I am trying to implement this in my own project where I have a views called "environments" and that is the one I'm trying to poll for changes. The "environments" doesn't have the same relationship as your article and comments example basically on the environments index page I want to poll for changes but it doesn't seem the index.js.erb file is being executed. Any help would be much appreciated.

Thanks,
Jay

Avatar

Great screencast that I just revisited.

I'm using it with Twitter Bootstrap and Simple_Form. With this in play the parent().hide() function hides the dropdown box, but does not hide the label...

Now I can get round this by created a div around both and hiding that, but that seems to be a bit cumbersome. Looking at the page source I don't see any other obvious divs to use.

Any thoughts?

Avatar

For me it seems to make no difference if ID or object is serialised: in both cases the state captured is the one when the delivery happens, not the state when delay is called... ??

Avatar

Sorry to bother, but is there something wrong with this video? It doesn't load, and all the download links are 404s.

Thanks

Avatar

You reminded me to doublecheck my whitespaces. Thanks.

Avatar

Did you manage to get this figured out?

Avatar

+1. I also need something like this. Have any of you figured this out?

Avatar

How can I filter the parent data by id and not by text?, I have a model that has 2 records with the same name, and when I select the parent it selects the other one with the same name.