RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

I have a small question. I've defined the "to_param" method but when I acess to /projects/1 (typing the URL) it doesn't change to /projects/1-name.

Here at railscasts it does changes the /episodes/63 to /episodes/63-name... how do you get that?

Avatar

Ryan your final tip was truly Steve Jobs-esque! Saving the best till last ;-)

Great episode as ever.

Avatar

@Ryan:

Can we use the same method to make a call to an item stored on a remote server? Say what if i want to http://google.com/somefolder/residingin/anotherfolder/somefile.js

Avatar

If like me you want to debug the daemon and want full backtrace logs instead of the truncated logs then do

Avatar

hi
i'm new on ruby on rails
i have user and book model
user model contains login actions when i wrote this to the application controller
current_user.user_name == "Writer"
i'm having an error message
--undefined local variable or method `current_user' for #<BookController:0x77131b0>
why i'm having this message?
how to fix

Avatar

Senthil,

You probably forgot to change column name from 'name' (as given in the railcast example) to the actual column name defined in your own DB.

So line from your model should look like this:

find(:all, :conditions => ['<<YOUR COLUMN NAME HERE>> LIKE ?', "%#{search}%"])

Avatar

Nevermind. I was confusing logical (example, &&) with bitwise (example, &) operators in MySQL after having read this http://dev.mysql.com/doc/refman/5.0/en/logical-operators.html

So it appears all the popular DB's do things like "SELECT 1 | 4" to return 5 (101). Nice.

Avatar

I believe that the named_scope technique here (which pushes the bit math out to the database to do the filtering on) will not work on MySQL, as MySQL bit arithmetic only encompasses TRUE and FALSE values and not all numbers, like it should. =/ Just an FYI (and also can anyone confirm?)

Avatar

thnaks for this great video.

I am facing a problem with will_paginate, if i want to use pagination along with <%= order %>, it is not working and giving me this error

undefined method `order' for #<WillPaginate::Collection:0xb6f1fa5c>
Thanks

Avatar

Hi

How you get formatted Role.all ?

Avatar

hi ryan
 great post. I managed to get searchlogic 2.3 working for me. When I use will_paginate, the only thing that breaks is the "order".
When i load my search results page, i seem to get an error indicating "order" is not defined.

I later found out that to get ordering to work again, i need to be able to generate the same url (with params) and append the order clause to it.

1) how do i do it?
2) with searchlogic 2.3.+ and will_paginate, how can we still maintain using "order" in the view as per your tute?

Avatar

but these parameters are not filtered if some exception occurs.

how filter parameters from exception log as well?

Avatar

Wow, the Ability class looks complicated! ... and that's only three roles! I dread what it would look like with more roles.

I'm also afraid that removing all that instantiating from the Controller code would be confusing for other developers who look at my code.

Avatar

Very nicely done Ryan. I truly appreciate all the hard work you put into this website for us. Thank you!

Avatar

Of all the supposedly-easy tips for Rails development, this one REALLY DID WORK as simply and easily as advertised, even on our complex database.

This has saved me hours.

Avatar

I like the way you do this : Tap ! VOILA !

RailsCasts is getting better and better!

I'm wondering if there's a way to do dynamics role from the website. For example as an owner of my company I want to create and give access to my finance manager to manage all of my employees' salaries. Not from the code or constant, but dynamically from a website.

Avatar

Someone can tell me if something like this in rails?

RBAC paradigm [2]

[1] http://nomadblue.com/projects/django-rbac/

[2] http://en.wikipedia.org/wiki/Role-based_access_control

Avatar

This is great! I'm pretty new to rails, but you make your presentations so clear and easy to understand. Such a task could be pretty hefty if your not used to some of the ideas you explain in this article but this code makes it seem so simple. Thanks!!

Avatar

This is great, I was looking for something like this and just found it..

Thanks for making it simple and straight

Avatar

thank you for the great help and greetings from me

Avatar

@AleBoi Thanks! That plus Pat's fields_for fork fixed all my issues. Thanks for your help all

Avatar

Great work as always Ryan!
I was wondering how would I implement something like this with accounts? I have many sub-domains (accounts) and a user can be a manager in one account and a rep in the other. Is there a way to send in Initialze(user, account)?

Thanks!

Avatar

It looks very nice but i am wondering how you can hide parts of the page which are not bind to an action, like a formfield or an extra navigation?

Avatar

Thanks for one of the reasons that mondays are nice!
:)

Keep up the good work, really appreciate it! It's the only screencast that I follow.
Now I'll see if I can use CanCan on one project I'm working on...

Avatar

@Jamie, Felipe, Stephen, thanks! Fixed. :)

@Nicholas, no, since the the comment.user will be nil for guests and therefore not match User.new.

Avatar

Hey Ryan,

CanCan looks fantastic. Nice job! I love how simple and declarative it is. Thanks for taking the time to write something like this up.

Avatar

Thanks Ryan, both for another wonderful screencast and for your new authorization plugin. I like the expressiveness it gives to the code.

Avatar

>Keep the "authentication-casts" coming
>have a full authenticated application

Say it with me: "Authorization"

NOT authentication.

Avatar

Ryan,

I seem to be having trouble implementing the search. I get the following error: SQLite3::SQLException: no such column: name: SELECT * FROM "posts" WHERE (name LIKE '%Body%')

Help please?

Avatar

I've been using CanCan on my latest project, with our easy_roles gem doing the user side role storage.

easy_roles supports bitmask storage and serialize.

Check it out at http://github.com/platform45/easy_roles

CanCan + easy_roles = Complete roles based authorization!

moderator edit: Jul 13, 2011 [link]

Avatar

@106 Libby
Try to add the following line to the respond_to method in your controller:

format.js {render :html=>@your_collection_of_DB_results}

It fixed similar issue for me.

BTW, I started experiencing this problem as soon as I updated the gems on my PC. A bit embarrassing.

Avatar

Hi,
I noticed in the source line that you were using the gems.github.com and on their wiki at github their using gemcutter. Which one should I use? Is gemcutter the most recent?

Thanks

Avatar

To really capture STDERR as well, I had to reverse these two:

>> log/rake.log 2>&1

Not very intuitive, but I believe this is how it works on many Unix-like systems

Avatar

Thanks, Ryan! Awesome screencast as usual.

Avatar

And another mention for authlogic with roles screencast! Thanks!

Avatar

I used this approach with remote form. The hash that's created when the form is posted (non-Ajax) is different from the Ajax (Form.serialize). The ajax hash does not create the desired hash. Instead of creating
[{:a=>1, :b=>2}, {:a=>3, :b=>4}]
it creates
[{:a=>1}, {:b=>2}, {:a=>3}, {:b=>4}]

Any solutions here? Is this a known bug with rails?

Avatar

@Michael Filbin

I had the same problem. To solve this I replaced "avatar.path(style)" with "avatar.to_file(style)" in the avatar_geometry method into the model... seems to work... With Heroku I've another problem with crop, the cropped image seems mantain the original ratio.

Avatar

How did you all solve the 406 Not Acceptable error? I see that others have it but haven't figured out how to fix it. Thanks!

Avatar

great episode once again! Thanks so much!

Avatar

Hello!, I have a question: Why you create a new method called "validate" instead put the "Error.add" code directly into rescue block?

Thanks a lot for this excellent podcasts.

Avatar

I'm trying to use the plugin and get the following:

Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
  * bin_path
  * searchd_binary_name
  * indexer_binary_name

Avatar

as per comment #14 that says:

you can disable timestamped migrations by putting this in your environment.rb file:

config.active_record.timestamped_migrations = false

------

I tried this, but it still uses the timestamp version. Any ideas why?

Avatar

Looks like SPAM is taking over again :-( Was nice there for a while.

Have you considered a plugin like Rakismet?

I'm going to fork the Railscasts repo, make some changes to hide comments if they appear spammy, until you flag them as ok. That way, even if spam still gets entered, at least it won't show up.

Avatar

I'm using Textmate [2009-08-29: REVISION 1509] and I don't find the footnotes plugin in the boundle. How can I install it??