RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

I use Rails 3 and I get the error message "undefined method `original_filename' for nil:NilClass"

Thank you for your assistance

Avatar

Thanks!
Altho you forgot an underscore on your first line

Avatar

On Rails4, this didn't work for me in config/environment/production.rb:

config.assets.js_compressor = Sprockets::LazyCompressor.new { Uglifier.new(mangle: false)}

but this did work:

config.assets.js_compressor = Uglifier.new(mangle: false)
Avatar

Well, turns out that the after_save was causing the worker to spin up over and over. As I said above, the solution is to put this within your model.

ruby
def enqueue_image
  ImageWorker.perform_async(id, key) if !image_processed && key.present?
end
Avatar

A little late to the game, but I did this as an elegant solution.

ruby
def enqueue_image
  ImageWorker.perform_async(id, key) if !image_processed && key.present?
end
Avatar

I use both Cells and Draper. They're entirely different.

Avatar

Update: I finally found a use case for Draper. I had a method that would choose a CSS class name for a particular model. It was too model-specific to put it in a helper, but too presentation-specific to feel good about putting it in the model. A presentation decorator turned out to be a good solution.

Avatar

Using filter_resource_access, the create action was reverting to non strong_parameters framework causing ActiveModel::ForbiddenAttributesError. Had to use filter_access_to :all instead. I hope that's not wrong... if not, I hope it helps others.

Avatar

This was a lifesaver! Now I can sleep well tonight! Thank You! Thank You!! Thank You!!!

Avatar

I'm also looking into this. Might just implement my own and I'll share my findings.

Avatar

even though the id is different its actually the same job running over and over.

Avatar

This is a perfect use case for a project I'm starting. I'm running into a little issue where the sidekiq worker runs over and over on the same original image. I'm not quite sure whats going on, but if anyone can help why it keeps running that would be great. I haven't modified the 'gallery-after' code at all either.

ruby
2013-07-23T16:38:10Z 36085 TID-ox5o30a8s INFO: Starting processing, hit Ctrl-C to stop
2013-07-23T16:39:01Z 36085 TID-ox5oe79dg Painting::ImageWorker JID-ee968f66ab665e06faa8215d INFO: start
2013-07-23T16:39:24Z 36085 TID-ox5oe79dg Painting::ImageWorker JID-ee968f66ab665e06faa8215d INFO: done: 22.813 sec
2013-07-23T16:39:24Z 36085 TID-ox5odqw08 Painting::ImageWorker JID-55da36d8eed3566f1dcdbb8c INFO: start
2013-07-23T16:39:47Z 36085 TID-ox5odqw08 Painting::ImageWorker JID-55da36d8eed3566f1dcdbb8c INFO: done: 22.585 sec
2013-07-23T16:39:47Z 36085 TID-ox5oe79dg Painting::ImageWorker JID-1adb5d111658cbe7eec89e6c INFO: start
2013-07-23T16:40:07Z 36085 TID-ox5oe79dg Painting::ImageWorker JID-1adb5d111658cbe7eec89e6c INFO: done: 20.703 sec
2013-07-23T16:40:07Z 36085 TID-ox5odqw08 Painting::ImageWorker JID-090912e3a2ea344478a4328c INFO: start
2013-07-23T16:40:31Z 36085 TID-ox5odqw08 Painting::ImageWorker JID-090912e3a2ea344478a4328c INFO: done: 24.182 sec
2013-07-23T16:40:31Z 36085 TID-ox5oe79dg Painting::ImageWorker JID-336203a55a260f03a70283d6 INFO: start
2013-07-23T16:40:47Z 36085 TID-ox5oe79dg Painting::ImageWorker JID-336203a55a260f03a70283d6 INFO: done: 15.941 sec
2013-07-23T16:40:47Z 36085 TID-ox5odqw08 Painting::ImageWorker JID-603b95db7f12733b4d2544e6 INFO: start
2013-07-23T16:41:01Z 36085 TID-ox5odqw08 Painting::ImageWorker JID-603b95db7f12733b4d2544e6 INFO: done: 13.247 sec
2013-07-23T16:41:01Z 36085 TID-ox5oe79dg Painting::ImageWorker JID-ace98b247b037499edc6474d INFO: start
2013-07-23T16:41:21Z 36085 TID-ox5oe79dg Painting::ImageWorker JID-ace98b247b037499edc6474d INFO: done: 20.634 sec
2013-07-23T16:41:21Z 36085 TID-ox5odqw08 Painting::ImageWorker JID-2598b2d38154f349b53fe6e5 INFO: start
Avatar

this might help you out https://github.com/j10io/sample_capistrano_app/ it's based on this tutorial as well as the comments in this thread.

Avatar

Place this in the Gemfile:

gem 'best_in_place', github: 'bernat/best_in_place'

Avatar

what about "/projects/yardwork" ?

How should I search with this pretty URL?

Avatar

Finding Foundation to be a nice addition to speeding up workflow nowadays :)

Avatar

Wow this is crazy:

1.9.3 unpached:
bundle exec rake -vT 18,51s user 2,03s system 94% cpu 21,768 total

1.9.3 pached:
bundle exec rake -vT 5,05s user 1,08s system 99% cpu 6,166 total

That is a big difference!

Avatar

Is this true? Is there a way to cache a fragment in the context of the currently viewing page?

Avatar

when you're generating your models, don't forget to add the reference id of the parent model. aka:

class Task < ActiveRecord::Base
belongs_to :project
attr_accessible :description, :done, :project_id
end

Avatar

PS> It's turbolinks. See my post to Lisa up above. ^^^

Avatar

Hey Lisa,
I figured it out: Turbolinks.

Take a look at Episode 390 (http://railscasts.com/episodes/390-turbolinks).

The way Ryan has written the code, it should be compatible with turbolinks; I think it's turbolinks that needs some work.

Basically I had to add a 'data-no-turbolink' attribute within one of my html tags. I tried to use a tight scope of div tags around the most troublesome coding, and worked out wider and wider (parent to parent) until it finally worked.

Unfortunately, I had to move so far out, I might has well put my data-no-turbolink in the 'body' tag. :(

I might just end up removing turbolinks. Good Luck, and I hope this helps someone else in this similar mess.

Avatar

I would point you here: https://stripe.com/docs/checkout and here https://stripe.com/docs/stripe.js.

I would use the first link and totally forgot about developing the forms and the needed js.

Avatar

@Ryan: thanks for good screen cast. it was help full my self but some customization require for me like:
<%= form_for object %>

I follow "New Article" need to pass one more pending below.
When(/^I follow "(.*?)"$/) do |arg1|
click_link(arg1)
end

thanks.

Avatar

Hi ryan,

thanks for your article.

How to make pre-populate on the form?
Because currently My form always did not pre-populate.

Thanks

Avatar

Hello,

I am having issues with the near by locations not showing up in my application. Any ideas as to why or what i need to do to fix it? I followed the tutorial and no luck. Thanks!

Avatar

Error: too many boolean clauses

Hey,
I've read many articles and concluded that I am getting this error due to 1024 option in solrconfig.xml file in solr/config directory.

I have tried to increase it upto 16384
and also tried to comment it out by doing this.

but getting same error.
yes i am using thousands of ids in search like

with(:id).all_of vids

where vids are the array of those ids.

is there any other option that i can fix this issue or can use IN kind of clause with search method ?

kindly guide me its really urgent,
thanks and advance,
best,
MK.

Avatar

I'm having the same exact problem. The code is solid, becuase if I do a refresh on that page, then my remove & add starts to work.

It's as if the javascript hasn't quite loaded yet.

Any ideas for the slow load of Javascript? Using ruby 2, rails 4.

Avatar

In Twitter its important to check the "Allow this application to be used to Sign in with Twitter" option when you configure your app. If you don't have it checked, when you attempt to Sign in with Twitter you will always see the Authorization page. When checked you can automatically sign-in.

For the callback url, I found 'http://127.0.0.1:3000/' worked for me.

Avatar

Has anyone figured out how to implement this for one-time payments as opposed to recurring/subscription?

Avatar

Adding a thor command to thor.json and the following method in custom_plan.rb seems to do the trick

ruby
  def thor
    require 'thor/runner'
    $thor_runner = true
    Thor::Runner.start
  end
Avatar

Any suggestions for getting Zeus and Thor to work together?

Avatar

Great article. I've been using this for a while and due to the number of PDFs that I create would like to create one or more 'partials' or similar to share standard methods (company address, header info etc.). Has anyone been able to do this. There are some queries that allude to this on Stack overflow, bu they are all quite old and don't use the pdfs folder

Avatar

Can I by any chance make the scroll trigger horizontal?
if (nearRightOfPage) or something similar? My I want my content to load as s but the trigger to be horizontal. Thanks.

Avatar

Maybe it's a small miss,
but I thing this $ should be passed to the func :

JS
jQuery ($) ->
  $('#id_to_autocomplete').autocomplete
    source: ['foo', 'food', 'four']

Anyway, thanks you for your screencasts, Ryan Bates ! :)

Avatar

I wonder if the :dependent => :destroy relationship should be in the user instead of the profile. This would probably only be a concern when transitioning between profiles, but if you want to delete the guest profile before adding the member profile you have to wait until after the user has been updated. On the other hand, if the user is destroyed, chances are you want the profile to be destroyed along with it.

Avatar

Does anyone have an example that actually uses Jquery File Upload and then processes with carrierwave afterwards?

Looking for a tutorial / example for the final step that Ryan refers to here...

"One thing that this version of the application does not do is generate thumbnail versions of each image. Instead the full version of each image is shown scaled down. There are a variety of ways that we could add this functionality. We could set up an EC2 instance and have that process the images"

Avatar

I have written an updated Gist for installing Ruby and Chef on a Ubuntu 12.04 32 Bit Server. You can check out the gist here: https://gist.github.com/codemis/6041247.

Avatar

Never mind.

Had forgotten to run:

sudo update-rc.d -f unicorn_appname defaults

Avatar

Did you find a solution for Unicorn not starting after a server reboot?

I have the same issue.

Avatar

Is anyone else getting the message (when opening up in Windows Excel): 'The file you are trying to open, .... , is in a different format than specified by the file extension. etc..' ? I don't get this when using Mac Excel (2011), but it seems to be an issue with Windows Excel (2010). Any workarounds?

Avatar

Thanks for reporting. If a value of data-tooltip is set then this value is used to identify the tooltip itself. Since in this case both are data-tooltip="true" when generated, both point to the same tooltip.

Try this:

    <div class="row collapse">
      <div class="small-3 columns">
        <%= f.label :name, class: "right inline", title: "Name of product", data: {tooltip: "name" } %>
      </div>
      <div class="small-9 columns">
        <%= f.text_field :name %>
      </div>
    </div>


    <div class="row collapse">
      <div class="small-3 columns">
        <%= f.label :price, class: "right inline", title: "Price in USD", data: {tooltip: "price" } %>
      </div>
      <div class="small-9 columns">
        <%= f.text_field :price %>
      </div>
    </div>
Avatar

Hello Ryan,

it works very nice but the problem is that images are not shown in pdf file generated by this gem. How can i solve this problem.
please help.

Thanks

Avatar

If you are having Error with default thumbnails (the nil error) consider this code:

def filename
super.chomp(File.extname(super)) + '.png' unless super.nil?
end

Avatar

I had a few issues with installing pow that I was finally able to resolve. My biggest issue was that apache was running so whenever it redirected, I would get the "It Works!" screen. Then the only way I could redirect was to go to http://myapp.dev:3000 (clearly not what I wanted!)
By stopping apache and preventing it from starting up I was able to get pow running. Took a while, so hopefully that will help someone else out.

Avatar

Nice tutorial! Love it!

I don't know if it's only me but i need to put this in /app/assets/stylesheets/config.rb :

ruby
require "zurb-foundation"

Because when I modified the bootstrap_and_overrides, appeared an error file.

I hope it helps someone

(Sorry for the caveman english)

Avatar

Agree with that eager loading. More on that: #22 Eager Loading (revised)

I think the intention of the screencast was to show how to use Dalli and not to focus on how to improve that example webpage.