RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Another great screencast! It is really helpful to see some of these older ones redone.

Looks like there is a small typo in the ASCIICast version where it says what to put in config/environments/development.rb: "exception_recpients" should be "exception_recipients".

Thanks again for all the hard work!

Avatar

Thanks for the great screencast!

When it turns to such things as DRY concept between Server <-> Client, I think about DSLs. Ruby is a great language for embedded DSLs, so why not to write a new DSL to write (for example) validation code with and then generate and execute from that DSL-code:
- Ruby no the server side
- JS on the client side

This DSL could be exandable by rails apps to allow any complexy operation. On the other hand, such DSL could also provide the natural limitations to users. For example, you can't ready access dom attributes or data base from such "DRY" code.

What are you think?

Avatar

You saved my day sir! Thank you!

Avatar

I have just run into the same problem! Has any one found a fix?

Avatar

What if I want to use two models in the nested set view? An example would be a dynamic restaurant menu where I have menu_sections and menu_items and i want to drag menu items to sections? How do I tackle this?

Avatar

Wow. That's nice and clean. In this case though, it's a fairly simple example. Recently, I needed a hidden field with the id of the record, and a visible field with the name of the record (for a accepts_nested_attributes_for population). Custom JS and HTML I found was a bit more flexible.

I made a 'search' action on the Users controller, which implements the search and rendering of HTML, rather than JSON. I prefer this way because:

  • It doesn't add complexity to the index method (contained functionality, esp since index uses a simple User.all, while search needs something more complex (for fulltext or sphinx or other things like that)
  • Rendering a properly classed HTML ul element and inserting that into the page I find gives much better style control. You can add things like image into it as well.

I prefer rendering HTML from an existing partial, than having to recreate that partial in Javascript and render it that way.

Avatar

Seems simple_form has quite a few bugs with Mongoid and doesn't work properly at all - the authors simply say "we don't use mongoid, we don't care" :( - Any alternatives that work well with Mongoid?

Avatar

If you add a status boolean in the friendship table you can do away with the invert_friendship assosiation

Avatar

Would love to see a follow up RailsCast or a Github example app that has built a Presenter for a Report or Dashboard. That is to say, a Presenter that incorporates data from several models into a single view.

Avatar

Very nice stuff Ryan !
You always are a precursor ;)

But what I'm asking is : to push further, why not using node.js and being able to transparently share code between the client and the server ?

Don't make me wrong, I love ruby and want to continue to work with rails !

Avatar

I have been able to make the IPN works for some use case however, when i pay without paypal account (mastercard,visa...) my app receive the params but the create! method fails silently. The logs contain the params sent by paypal, and there is no significative difference between an IPN from a paypal account and a non-paypal payment.

How can i know what fails in the create! method?

Avatar

I'm having many issues w/ it working, especially when deployed to production. The gemfile route does not work.

Avatar

A, thx, cool. a bit hidden though :)

Avatar

+1 still very interesting proof of concept

Avatar

Just a quick note for anyone using mongomapper or mongoid, or anything that requires removing active record but removing the line

ruby
require 'rails/all'

make sure you add:

ruby
require 'sprockets/railtie'

this is not currently documented

Avatar

nginx chef cookbook using the nginx app template described in this episode.

I always let the apps define the rack server. Some are fans or Thin while others go with Unicorn (or Rainbows). Capistrano+Foreman are a good combo for this. This is how I go about deploys.

Avatar

Nice. I was looking for something like this. I tried this, but get this error:

A VCR cassette is currently in use.  You must eject it before you can turn VCR off. (VCR::Errors::CassetteInUseError)
      /Users/dev/.rvm/gems/ree-1.8.7-2011.03@mclax/gems/vcr-2.0.0.beta2/lib/vcr.rb:124:in `turn_off!'
      /Users/dev/Projects/mclax/features/support/hooks.rb:25:in `After'
Avatar

I too would like to know what people are using for Autocomplete and Autosuggest.

Also, for those that can't find the wiki from the links, the new active link for Sunspot is:
https://github.com/sunspot/sunspot/wiki

Avatar

Im using rails 3.0.5...do you know if this is supported for rails 3 apps?

Avatar

I'm seeing some pretty serious redraw bugs with SoapUI (Mac 10.7.2, latest java update). Are there any other similar tools?

Avatar

Hi there, Ryan says in the video that we should gitignore the stripe api key initializer file so to avoid it being divulge in general development. But when the time comes that we do need to push it to the production server, like Heroku which I use, how do you go about it? do you do something with git add just for that one push?

Avatar

What's the browser just you used、so easy to switch IE or firefox

Avatar

I'm having troubles with mercury params (Rails 3.1.1rc1). I can read from console

{"content"=>"{\"article_title\":{\"type\":\"editable\",\"value\":\"hello-ise\",\"snippets\":{}},\"article_body\":{\"type\":\"editable\",\"value\":\"\n \tworld\n \n \t \",\"snippets\":{}}}", "locale"=>"fr", "id"=>"1"}

Somehow, under rails 3,1, mercury seems to escape parameters. And params in controller is wrongly interpreted.

Am I the only one to feel stupid?

Thanks to enlight me

Avatar

How do you add authentication checks on the /editor/.* routes?

I mean, I know you can:

  • hide the link to the editor when not authenticated.
  • refuse updates from the editor when not authenticated.

But I'd prefer the user be kicked out of the editor in case he/she has a bookmark to the editor and isn't logged in.

Avatar

I find I am having the same issue -- files in vendor/javascripts are not being included unless I explicitly include them using your method. Seems strange. This is not the documented behavior?

Avatar

you can use

ruby
 if request.headers['X-PJAX']
    render :layout => false #add this option to save the time of layout rendering
  end

Alike, you can use request.headers['X-PJAX'] + parameters to determine what to render in templates too, if you feel like it

Avatar

I'm guessing this is a little bug, but why would you want the reset_token to be considered expired if it is less than 2 hours old? shouldn't it be if it is more than 2 hours old??

Avatar

I just finished the Rails implementation of the EchoService, hopefully it will be of use to someone :)

Avatar

Shouldn't line 4 be:

ruby
<%= text_field_tag :search, params[:search] %>

params doesn't take a : in front of it

Avatar

Mac Martine - can you elaborate on how you got this working for rails 3? I have everything loaded with no errors but the javascript doesn't seem to run.

Thanks!

Avatar

I agree. 'Stretch', but cool at the same time.

This technique buys you two things:

  1. You can support clients without Javascript (else you can just have the client do all the rendering and skip the Ruby-JS bridge entirely).
  2. You don't have to duplicate code between languages.

However, the bridge is completely closed because JS runtimes are not equivalent. For example, how do you deal with timezones (you're making a new Date which means you can have some weird ordering issues if the day is different depending on whether the server/client are in a different zone.

Really cool though :-)

Avatar

Thanks. Interesting cast.

Personally, I'd go one step further and completely ditch the initial rendering of the page. Then you can do all the rendering on the client side. The nice thing about that is you don't need to do the dual-nature templates. You drop support for clients without Javascript, but depending on your site, this may be OK.

Avatar

It would be awesome to integrate the history button with something like paper_trail. Is that the intention? I couldn't figure out how to implement this if it's already there. Amazing editor by the way!

Avatar

Thanks for the putting this screencast together! So awesome! And as always, useful -- even if it is my own project.

I've taken notes on some things that could be made nicer or simplified, so it's been invaluable for me. And I'll be pushing updates that address some of the things that could be improved on in the next few weeks.. I've also update the documentation to include a link to this railscast.

Avatar

Quick question, I'm currently writing integration tests for a Sorcery powered Rails 3.1 app. I'm having some issues when trying to fill in the login form. This is how my test is set up:

ruby
user = create(:user)
visit login_path
fill_in 'username', :with => user.username
fill_in 'password', :with => user.password
click_button 'Log In'
find_link(user.username).visible?

That current test setup doesn't work; however, if I do:

ruby
fill_in 'password', :with => 'foobar'

It does work. Just wondering why this isn't working for me. I assume it has something to do with encrypting the password during setup or something.

Here's my factory if anyone is interested:

ruby
sequence(:username) { |n| "foo#{n}" }
password 'foobar'
email { "#{username}@example.com" }
Avatar

This library appears to be very high quality and very well thought out. It doesn't pigeonhole you into any set back-end implementation, and focuses on a very flexible and intuitive front-end.

-Doug Puchalski
PENSCO
fullware

Avatar

I'm seeing that too. In the browser I get a pjax response and the page paints, then immediately I get a full page refresh. Watching the development.log in my app, I see (for example) a GET "/projects/28?_pjax=true" which runs the controller and renders the views. Then immediately there is another request "GET /projects/28" which again runs the controller, renders thew view and sends it back to the browsers. On the second request all the assets (images, javascript, etc...) are sent also.

I haven't found a solution yet.

Avatar

Unfortunately both of those aren't actively maintained, I doubt that either works on Ruby 1.9 (if you search you may find a fork of one or the other that could do the job).

Doing it yourself completely isn't as hard as you may think though. Today I finished up an article on my blog on this topic, the example service I present in it is written using Sinatra (and not Rails).

I'm working on building an example of the same SOAP service inside of a Rails app: https://github.com/mkremer/echo_service_rails. I'll expect this example to be finished somewhere in the coming days

Avatar

Hey everyone,

does anyone got :rowspan and/or :colspan working? I've installed the prawn-layout gem and tried this -> (https://github.com/blaxter/prawn-layout/blob/3a80fa65d7c06774c615d6f64b5d24a4a2af784f/examples/table/table_rowspan.rb) example, but nothing happens.

I really want to use prawn, but i really need colspan and rowspan.

Thanks.