RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Thank you Graeme, it was very helpful

Avatar

I, too, would enjoy something on sockets other than the Faye episode.

Avatar

I switched over to strong_parameters and this has broken the basic CSV import method outlined in this screencast I am using on a Documents model. Wondering what syntax I would need to use to fix this line to work with strong_parameters.

document.attributes = row.to_hash.slice(*accessible_attributes)

Avatar

how did you solve your problem mahmoud?

Avatar

Not working with Office in Windows and Google Docs.
Office in Windows and Google Docs don't show de spreadsheet (corrupted file) :(

Avatar

Hi Ryan, this tutorial is great. Do you think is possible to have a similar tutorial for socket/comet/push interupt service?

Avatar

awesomeness on every railscast!

Avatar

Please expand on not using Delayed_job with rails directly

Avatar

Thanks. The module inside class was suggested by @rbates himself.

Avatar

I'm trying to import an excel xml that was created like 362-exporting-csv-and-excel http://railscasts.com/episodes/362-exporting-csv-and-excel?view=asciicast

I get the following error

c:/ruby/lib/ruby/gems/1.8/gems/parseexcel-0.5.2/lib/parseexcel/
olestorage.rb:354:in `get_header': OLE::UnknownFormatError
(OLE::UnknownFormatError)

ruby-roo/ parseexcel cannot read the excel xml file type?

Avatar

Im having problems getting it to import without adding in new records rather than updating existing. Sometimes it doesn't appear to be doing anything. I cant figure why though!

Avatar

I believe jQuery is clever enough to work out that it's JSON anyway.

Avatar

You're defining a class name Portrait as descending from ActiveRecord::Base.

Then you redefining it without ActiveRecord. You can't do that.

Suggestion: wrap your Portrait class (non ActiveRecord) in a module with the name of you app. If you app is called Store, so

ruby
module Store
  class Portrait

  end
end

Also, don't put a module inside the class like this. Module are not meant to be used as classes.

Avatar

Thanks! I have been looking for something like this.

Avatar

For security concerns, is there any possible way to disable the route-showing feature and /rails/info feature?

Avatar

Somehow I get nil values for crop_x, crop_y, crop_w, and crop_h,

I've put
"
attr_accessible :name, :email, :password, :password_confirmation, :avatar,
:crop_x, :crop_y, :crop_w, :crop_h
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
"
already.. it shows correct values in the hidden text field and the after-save debug dump on browser, but cropping? ALWAYS evaluate to false!..

Anyone know why this is?

Avatar

http://js2coffee.org/

Converter JS -> Coffee and Coffee -> JS maybe that helps

Avatar

I'm trying to use the newer Mercury editor and it is not saving. If anyone can help I would appreciate it:

http://stackoverflow.com/questions/14366307/mercury-editor-0-9-0-cannot-save-changes-in-rails-3-2-11

Avatar

Has anyone used this with bootstrap modal ?, when I add a modal with fileupload not found.

Avatar

Hi Amunda, if I understand your question correctly, it's not a problem. That if statement is only checking whether the comments container element is on the page. If it is, then we know we're on the right page, and it would call CommentPoller.poll(). if its not, then we dont need to use the JS

Avatar

Hey Ryan,

thank you for the great screencast.

It would be nice if you make another screencast on active_admin on some advanced topics like file uploads and integration with globalize3.

Cheers

Avatar

I am trying to install fnordmetric gem in my rails application. I installed the gem with this command sudo gem install fnordmetric. Gem is installed but i am getting this error when i run the server through script/server

invalid gemspec in illformed requirement in /usr/local/lib/ruby/gems/1.8/specifications/fnordmetric-1.0 gemspec
and in /code/ts-delayed-delta/ruby/gems/1.8/specifications/fnordmetric-1.0 gemspec

I updated the gems using sudo gem update --system. Still i am getting the same error.

Can anyone suggest me how to overcome this problem..?
Thank you in advance

Avatar

If you're using this now, note that the example in the github repo is incorrect
https://github.com/rails/pjax_rails

should be:

$('[data-pjax-container]').pjax('a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])');

not:

$('a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])').pjax('[data-pjax-container]');

see issue:
https://github.com/rails/pjax_rails/issues/51

Avatar

Is there a way to use this for pages that contain mostly static content, that is only updated whenever the app is updated?

I have some static pages (tutorial, help, contact, about, etc.) that use embedded ruby for for some things, but should otherwise be cached.

Avatar

Yup. same problem for me regardless of how remember_me checkbox is checked. Permanently logged in even between browser launches unless explicitly signing out…

Avatar

didn't work for me. I have a select_tag which is not part of the form. I guess that is the problem

Avatar

I trying to use the dynamics search scope like this

ruby
pg_search_scope :advance_search, lambda {|*args, query|
      return {:against => args,
      :query => query,
      using: { tsearch: { dictionary: "spanish"} } }
  }

def self.searchadv(title, place, category)
    advance_search(:title => title, :place => place, :category => category)
end

But I'm getting wrong number of arguments (3 for 4) some help please

Avatar

Love the example! I also think polling is a viable solution for many applications. Unfortunately, I'm not a big fan of coffee script so JS based episodes like these require a bit more focus on my part...but maybe that means I should start using coffee script?

Avatar

What would you recommend when it comes to the /spec/vcr directory and version control?

I imagine it would be pretty safe to ignore the directory, because the cassette files would be generated on the first test run for each checkout of the repository (assuming you use record: :new_episodes)

On the other hand, if you're communicating with an unreliable server, it could be a pain to re-record the interactions correctly.

Any thoughts?

Avatar

Awesome as usual. By the way i was wondering shouldn't this method CommentPoller.poll() be outside the 'if' clause because if the comments is < 0 then it will never poll again

Avatar

How do you write a functional test for the login?

Avatar

I'm new to Rails, and I'm having trouble figuring out how the logout link, session_path("current"), is routing to the destroy method in the controller?

Avatar

I use the gem s3_direct_upload inspirated by the code, but I have a problem.

Upload and progress bar works perfectly, my problem is :

The url of the uploaded file is a part a a Medium I create. The Medium contain "name", "description", "file_url" etc.

I don't display the S3 form at the creation of my medium, after saving, I redirect_to the Edit action and then display the S3 form to add a file. I tried to set post:media_url(@medium) or post:medium_edit_path(@medium) but it doesn't work cos I guess update require PUT and not POST.

So, is it possible to implement PUT with the gem or may I do something different ?

Thanks for your help

Avatar

I am namespacing my concerns as demonstrated in the tutorial.

I have a class Portrait and a concern Portrait::ToHash defined as

ruby
class Portrait < ActiveRecord::Base
  #my class
end

class Portrait
  module ToHash
    #my methods
  end
end

but I get this error: superclass mismatch for class

The error goes away if I do this:

ruby
class Portrait < ActiveRecord::Base
  module ToHash
    #my methods
  end
end

I have 5 models and I do not need to inherit the class from ActiveRecord::Base when defining the concern in any of the others. Just this one.

Any clues what could be happening?

Avatar

Great explanation of polling, thanks very much. I love how you build on extra functionality in your videos and go basic > intermediate > advanced with the extra features you keep adding on.

Avatar

I thought that too, I used to do e.preventDefault() all the time until I looked up this Stack Overflow article: http://stackoverflow.com/questions/134845/href-attribute-for-javascript-links-or-javascriptvoid0

Now I just use javascript:void(0) all the time!

Avatar

I concur with Kevin. I've come to Ruby & Rails with a background in other programming languages and frameworks (C, Perl, Scheme and Java). The rails API doco is somewhat half-baked, so I am very interested in deep-dive walkthroughs and I have no problem keeping up. And the pause button is there if one needs to chew on the substance a little more.

Avatar

This is an outstanding episode! So concise and helpful.

Just one question... One small JQuery-related thing through me for a loop.

in /app/assets/javascripts/subscriptions.js.coffee, why was the change made to:

$('#new_subscription')[0].submit()

?

What is the [0] for? I have not seen that before.

Avatar

I like setting the href to 'javascript:' and skipping e.preventDefault()

Avatar

Great tutorial! You can even take it a step further and only pull when the user gets down to the comments area. It's relatively easy to get info about where the browser viewport is in proportion to other elements.

Avatar

It seems that indexing columns doesn´t have any effect when you are ALSO searching against associated tables

From PGSearch :
It is possible to search columns on associated models. Note that if you do this, it will be impossible to speed up searches with database indexes. However, it is supported as a quick way to try out cross-model searching.

Anyone knows about this?

Avatar

I'm fairly new to rails. Would someone explain why jquery plugins work normally on localhost but fail to do so when deployed to heroku

Avatar

Hi!

This is most likely because of your version of Thinking Sphinx. Upgrading to 2.0.14 should fix the problem.

2.0.14 - January 2nd 2013
* Fix model loading for Rails 3.2.9 when subdirectories exist (Kenn Ejima).

https://github.com/pat/thinking-sphinx/blob/master/HISTORY

Avatar

I have a question.

For the expression:

Rails.cache.fetch([:category, category_id, :name], expires_in: 5.minutes)

Why you didnt use :category_id here, why category_id do not need to symbolize, but category and name need to?

Avatar

I couldn't get the following to work:

javascript
$('document').on 'click', '.edit_task input[type=checkbox]', ->
    $(this).parent('form').submit()

I had to use:

javascript
$('document').on 'click', 'input[type=checkbox].edit_task', ->
    $(this).parent('form').submit()

This was on jQuery 2.1.4 with Firefox 17.0.1 and Chrome 24.0.1312.52-beta on Linux.