Sign in through GitHub

Recent Comments

Avatar

Did you have any luck with this? I am running into the same problem.

Avatar

Hey Ryan,

Is there any reason not to have the method missing check the @object first? As the presenters are usual about a particular model, and delegating a dozen items can be painful.

Something like:

ruby
 def method_missing(*args, &block)
    if @object.respond_to? *args[0]
      @object.send *args, &block
    else
      @template.send *args, &block
    end
  end

Thanks for the great episode!

Avatar

Has anyone got jQTouch working with Rails 3.1+ and the asset pipeline?

Avatar

Ran into this exact same issue a few weeks ago, where I had ActiveAdmin updating records but the Sweeper wouldn't observe the model on normal CRUD. I attempted to have the sweeper get called as an observer but I still couldn't figure my way around it, so I fell back to using Rack::Cache (and updated with suggestions from Ryan's screencast earlier in the week).

Avatar

Thank you Ryan, this screencast is very informative for me.

+1

Avatar

I agree, I think it would be more practical to be able to attach the sweeper to a model, you may want to expire the same pages or fragments in several controllers, rake tasks ... I suppose the problem is that the views are related and only accessible by the controllers and not models but it feels a little bit weird.

Avatar

I'm wondering why the cache sweepers are tied to the controller.
Some time ago I was writing about this here: http://www.railstoolkit.com/posts/rails-cache-sweeper-confusion

Avatar

+1 for dynamic page caching revised...

Avatar

So, the more I get into it, the more questions I have...

Also not having any luck getting it work with multiple checkboxes. Anyone have that setup working?

Thanks.

Avatar

Anyone using this with the jQuery datepicker? I haven't been able to get it to work - the form just never submits, even though there is a date selected.

Thanks for any help :)

Avatar

This is great.
Thanks a lot Ryan!

Avatar

I think I followed every step of this screencast, but I could not start unicorn. It seems that the pid files are busy (?). Any idea on how to solve this problem?

I'm using unicorn 4.2.0, which is the newest version of the gem.

When I run " sudo service unicorn restart" I get:

bash
kill: 71: No such process

Couldn't reload, starting '/vagrant/bin/unicorn -D -c /vagrant/config/unicorn.rb -E development' instead
master failed to start, check stderr log for details

And here is my sderr log:

bash
I, [2012-02-02T16:29:54.313595 #2007]  INFO -- : unlinking existing socket=/tmp/unicorn.todo.sock
I, [2012-02-02T16:29:54.316860 #2007]  INFO -- : listening on addr=/tmp/unicorn.todo.sock fd=3
/home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:202:in `rename': Text file busy - (/vagrant/tmp/pids/0.933261511233375.2007, /vagrant/tmp/pids/unicorn.pid) (Errno::ETXTBSY)
        from /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:202:in `pid='
        from /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:133:in `start'
        from /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/unicorn-4.2.0/bin/unicorn:121:in `<top (required)>'
        from /vagrant/bin/unicorn:16:in `load'
        from /vagrant/bin/unicorn:16:in `<main>'
Avatar

I have to agree with @EnricoCarlesso I would like to understand if there is a way to run Pry with Foreman. It seems that it works okay except you cannot see your input when running a web worker plus regular cron-esque worker. I set the unicorn web workers down to 1 so that it wouldn't conflict in that regard, but still the input is an issue.

Avatar

Thanks for taking the time to explain this, it's always nice to see all the options and how it affects the http header. Keep up the good work!

Avatar

Thanks, bitencode. This works great!
And thank you all, too!!

Avatar

Did you manage to get a solution for this?

Thanks.

Avatar

On using the above procedure, I get the following error message:

undefined method `error_message' for #ActionView::Helpers::FormBuilder:0x9fa7f54

Can anyone help me?? Thanks in advance..!!

Avatar

Is there a way to do API versioning and inheritance with jbuilder?

Avatar

Right. I get why it wasn't working.

My question is how I could bypass the rack::cache layer for logged in users.

I could certainly do #169's approach, but I'd far rather optimize for the 99%, leaving my code pretty much in tact, and just serve up the site to the very small % of logged in users. My actual in app caching is optimized enough I'm not too worried.

I will look into #305, but I've scoured the net and can't figure out a way to disable rack::cache for requests based on cookies, which is what I would need to do here.

Avatar

Another awesome screencast Ryan!

Avatar

It seems like an appropriate episode to revise… Thanks Ryan!

Avatar

Setting :public => !user_signed_in? won't work, because when the first user comes, she won't be signed in and so the cache will be set, and when it gets set it won't hit the app to check it again.

I imagine you would have to override some behaviour in the rack::cache itself or put another middleware before it. But I don't think it would be worth it.

You should try the solution form epsiode #169 mentioned above. If you really want to get dirty with middlewares you can try to mix it with episode #205 on authentication with Warden, but as I said I doubt it's worth the effort. You'll just get into a mess that way.

Avatar

I had the same issue. Facebook just doesn't seem to work with localhost unlike Twitter. But I did test it against a public ip that I own and it works as expected. If you don't have a pulbic ip you can try going with some kind of dynamic dns solution.

You can also try looking up this Stackoverflow topic, but your settings seem correct. Maybe lvh.me will work though.

Avatar

+1 to revising episode 169.

Does anyone know if you can simply bypass rack::cache for logged in users and still take advantage of http caching for 99% of my users that show up anonymous?

I set :public => !user_signed_in? accordingly, but rack::cache will still serve a public cached copy if it already had one to logged in users.

Any help would be appreciated! Thanks for the awesome railscast as always!

Avatar

I was hoping you would do a railscast on Jbuilder! How about one on Grape, it's got some pretty cool features. If you wanted to do a 5min Pro on Grape I'd be ok with that :)

Avatar

"I have some Kryptonite for you Superman!" genius

Avatar

I have followed the omniauth devise facebook app as explained by Ryan in episode 235.After the user authorizes we are getting the error at http://localhost:3000/auth/facebook/callback?code=13444...

The following are the facebook settings :
App Domain : localhost
siteurl: http://locahost:3000/
canvas url: http://localhost:3000/auth/facebook/

I have also tried using 127.0.0.1 in the place of locahost for facebook settings, but i am getting a invalied domain error on facebook settings page.

please tell me where am i going wrong?

Avatar

Bad Luck..Date picker is coming but still the values are changing only in the first text field only...every other text fields remain empty....!!! Is anyone out there can help me???

Avatar

The show notes have 'views/articles/show.json.builder' as the one path, but it should be '.jbuilder'

Very timely episode. I'm implementing it now!

Avatar

I agree with julescopeland! I was just thinking about this topic.
Screencast is awesome.

Thanks Ryan.

Avatar

Great tuto ! Useful for everythin. Thanks
Please note that it should be :

bash
if [[ -f Rakefile ]];then
#....
fi

and not

bash
if [[ -f Rakefile]];then
#....
fi
Avatar

Make sure your Rake task is loading the full Rails environment: task :foo => :environment. It should have access to the key/value store then.

Avatar

It depends on what you're doing in the middleware, but usually it will only add a quick "if" condition and a couple method calls to the stack. In theory it is slightly slower but nothing that will be noticeably slower.

Avatar

I am trying to avoid renaming the titles of the episodes when I revise them, so I understand that can make it a little misleading.

Avatar

I just discovered RABL - me gusta!

Avatar

RABL is similar, and I will likely do an episode on it in the future since it is different enough from Jbuilder. What I like about Jbuilder is its simplicity (it is just two small files). But RABL has more to offer in its interface.

Avatar

Good question. You can't use the cache helper method because that is designed to work with ERB. However you can use the read_fragment and write_fragment methods to manage the cache directly.

Avatar

Great point. Sometimes you can get by with making the status panel more generic such as "My Account" so it can work for any situation. However that isn't always wanted.

Alternatively you can use JavaScript to load the dynamic content. See Episode 169: Dynamic Page Caching on how to do this. I plan to revise that episode in the near future.

Avatar

Yes it is but RABL offers you JSON and XML.

Personally, I preferred RABL. I guess its up to everyone.

Avatar

Ignore me. Got it sorted now. Added gem 'bcrypt-ruby', :require => 'bcrypt' to my gemfile and it works perfectly :)

Avatar

Can't you just use an ordered list <ol>?

Avatar

This is what I do and it works quite well.

Avatar

Thanks for that link murdoch. Useful little Rack example.

Avatar

I'm getting the same problem. gem 'bcrypt-ruby' is in my gemfile and I've run bundle install. Still no joy.

I'm on OSX and running Ruby 1.9.2 (via Rbenv) and Rails 3.2.0.

Any ideas?

Avatar

Is jBuilder similar to RABL? (I think it is...) If so - what are the pros/cons of jBuilder vs RABL?