|
skidooer posted:I'm not convinced it's better, but I do like some of the aspects of it. Thoughts? I can definitely see where it would be helpful if you have a different group of people creating the application logic and the actual page design. Right now the view is where they sort of collide, but by separating views and templates out even further this way you can keep them at least a little bit more separated. On the other hand if your designers are like mine, they just tell you what it should look like and you code the whole thing. I think if this is the case it's taking separation of logic and design a little bit too far. Basically too much complication for not enough gain.
|
# ? Nov 28, 2007 14:40 |
|
|
# ? Apr 23, 2024 13:25 |
|
skidooer posted:find(:all, :joins => 'INNER JOIN bar ON bar.foo_id = foo.id') You can do this with named associations like :include now (if you use edge). find(:all, :joins => :bar)
|
# ? Nov 28, 2007 15:24 |
|
Is there a way to disable SQL logging for some statements within Rails? I have an images table that I'm uploading somewhat large files to, and the SQL logging is causing all sorts of Terminal.app problems. I don't want to disable SQL logging completely in the development environment, but I would like to be able to not have it log those statement that are doing INSERTs into the images table.
|
# ? Nov 28, 2007 23:30 |
|
Hop Pocket posted:Is there a way to disable SQL logging for some statements within Rails? I have an images table that I'm uploading somewhat large files to, and the SQL logging is causing all sorts of Terminal.app problems. I don't want to disable SQL logging completely in the development environment, but I would like to be able to not have it log those statement that are doing INSERTs into the images table. If you're putting them in their own column, I suppose you could use filter_parameter_logging, but that might not completely fit your needs. This might also cause problems if you have columns similarly-named to your image data column elsewhere in your models. The Journey Fraternity fucked around with this message at 07:09 on Nov 29, 2007 |
# ? Nov 29, 2007 07:07 |
|
I'm writing a little networking site and I can't figure out how to get anything into a table without using a form. Forms are great when registering users or creating groups, but I want the group table to have a 'creator' attribute that holds the user id from a session. I know how to get the id from the session, but have no idea how to get it inside the table upon creation. Here is the code from my new.rhtml from the group view (REST is awesome) code:
|
# ? Dec 4, 2007 07:18 |
|
poemdexter posted:I'm writing a little networking site and I can't figure out how to get anything into a table without using a form. It makes the most sense to me to put that in your controller instead. So something like: code:
|
# ? Dec 4, 2007 07:35 |
|
zigb posted:It makes the most sense to me to put that in your controller instead. So something like: @newGroup = Group.new(params[:group]) would save a line. Not that it really matters, I guess. Anyone know of a quick/easy way to provide 'validates_X'-style validation on non-model checks? Like if a .find comes up blank, show an error/alert, instead of having to code that exception explicitly every time?
|
# ? Dec 4, 2007 07:41 |
|
poemdexter posted:I want the group table to have a 'creator' attribute that holds the user id from a session. code:
MonkeyMaker posted:Anyone know of a quick/easy way to provide 'validates_X'-style validation on non-model checks? Like if a .find comes up blank, show an error/alert, instead of having to code that exception explicitly every time? code:
skidooer fucked around with this message at 09:04 on Dec 4, 2007 |
# ? Dec 4, 2007 08:22 |
|
MonkeyMaker posted:@newGroup = Group.new(params[:group]) would save a line. Not that it really matters, I guess. code:
|
# ? Dec 4, 2007 09:26 |
|
poemdexter posted:I'm still new to both Ruby and the Rails gem. I would really recommend using edge rails over gem rails. You get to take advantage of all of the new improvements and such. And rails 2 is due out soon anyway. My favorite way to do it is to check the trunk out into your own repo using piston. It's a lot nicer than svn externals.
|
# ? Dec 4, 2007 09:43 |
|
I've got an ActiveRecord question. Say I have a site for people to say which movies they liked certain actors in. So there are three tables user(id, login) movies(id, title) actors(id, name) The relationships are A User can see many movies A User can like many actors in a particular movie Which makes the join tables something like users_movies(user_id, movie_id) user_movie_actors(user_id, movie_id, actor_id) I can't figure out how to correctly describe this in ActiveRecord. I think the result should be a User object that contains a list of Movies they've seen, which contains the Actors they liked in that movie. Does anyone know how to describe this to ActiveRecord? I can't figure out how to have a (user, movie) pair have a many to many relationship with actors.
|
# ? Dec 4, 2007 12:10 |
|
I would do it like thiscode:
|
# ? Dec 4, 2007 13:46 |
|
poemdexter posted:This was the simplest way to go about it. Thanks. I have no idea what everyone else's code does, but I'm still new to both Ruby and the Rails gem. Based on the information you have given, I'm assuming your models look something like this: code:
code:
code:
|
# ? Dec 4, 2007 15:07 |
|
problem solved.
poemdexter fucked around with this message at 01:25 on Dec 5, 2007 |
# ? Dec 5, 2007 00:27 |
|
OK, I'm trying to wrap my brain around this RESTful stuff, and I think I've got it. I was experimenting with refactoring one of my existing apps to REST, but here's the snag I run into. For my "user" controller, I have my routes set up like so: code:
|
# ? Dec 5, 2007 00:45 |
|
what could be the reason for when I try to update a friendship, I get redirects after completion going to: http://localhost:3000/users/2/friends?friend_id=1 with this code in the update method: code:
http://localhost:3000/users/2/friends with this code in the create method: code:
|
# ? Dec 5, 2007 01:30 |
|
Lamont Cranston posted:I can't figure out how to do this in REST with map.resource. code:
code:
|
# ? Dec 5, 2007 02:13 |
|
What's the usual way of setting a page's title? All my pages use the same layout, I'm assuming I should put something like this in my layout:code:
|
# ? Dec 5, 2007 04:09 |
|
Al Azif posted:What's the usual way of setting a page's title? All my pages use the same layout, I'm assuming I should put something like this in my layout: I do it in the view. Sure I may be just going <% @title = "You own " + @dog.name + "!" %>. But that's one less thing to have to make sure I do if I do screwy things with renders.
|
# ? Dec 5, 2007 04:56 |
|
You can also use content_for to supply extra information to your layout. application.rhtml code:
code:
|
# ? Dec 5, 2007 05:00 |
|
What would be the sanest way to add a "global" variable accessible by all controllers/views in an app? At the moment I've just got a method in the application helper that returns the variable but I was wondering if there was a more "rails" way to do this.
|
# ? Dec 5, 2007 09:17 |
|
Hop Pocket posted:You can also use content_for to supply extra information to your layout. Something like: code:
SeventySeven posted:What would be the sanest way to add a "global" variable accessible by all controllers/views in an app? code:
skidooer fucked around with this message at 17:37 on Dec 5, 2007 |
# ? Dec 5, 2007 17:33 |
|
Just a constant, nothing fancy.
|
# ? Dec 5, 2007 19:53 |
|
SeventySeven posted:Just a constant, nothing fancy. I used environment.rb to store a constant with my Google API key, that might work for you.
|
# ? Dec 6, 2007 01:14 |
|
MonkeyMaker posted:Anyone know of a quick/easy way to provide 'validates_X'-style validation on non-model checks? Like if a .find comes up blank, show an error/alert, instead of having to code that exception explicitly every time? If you use .find_by_id in place of .find, then if that .find_by_id comes up blank it will return nil instead of an error. code:
code:
Nolgthorn fucked around with this message at 03:50 on Dec 6, 2007 |
# ? Dec 6, 2007 03:45 |
|
Nolgthorn posted:If you use .find_by_id in place of .find, then if that .find_by_id comes up blank it will return nil instead of an error. This thread is so great for little tidbits like this. Thanks
|
# ? Dec 6, 2007 04:25 |
|
I found this very useful when you need to sandwich a custom method that should be called when calling existing Rails method yet being able to still use it later on... Sorry, this sounds confusing... Read this: alias_method_bling http://errtheblog.com/post/1109
|
# ? Dec 6, 2007 05:39 |
|
Does anyone have a copy of Agile Web Development with Rails that they might want to sell?
|
# ? Dec 6, 2007 17:08 |
|
I'm trying to write sort of a short-and-sweet authentication permissions system. As it is right now, I know how I think I want it to work but I'm having trouble making it escape the controller action that was running if validation fails. Controller in some action: code:
code:
I'm at a loss as to how to put code safely after calling permission_required in my controller, without worrying about it getting executed anyway after the user is redirected.
|
# ? Dec 6, 2007 19:07 |
|
Nolgthorn posted:I'm at a loss as to how to put code safely after calling permission_required in my controller, without worrying about it getting executed anyway after the user is redirected. code:
skidooer fucked around with this message at 19:47 on Dec 6, 2007 |
# ? Dec 6, 2007 19:40 |
|
Can anyone tell me why this WON'T loving INCREMENT?code:
|
# ? Dec 7, 2007 10:03 |
|
SeventySeven posted:Can anyone tell me why this WON'T loving INCREMENT? Based on the API source, I believe it's expecting the name(or maybe the symbol) of the attribute. Try: @item.increment!('collected')
|
# ? Dec 7, 2007 10:14 |
|
Hammertime posted:Based on the API source, I believe it's expecting the name(or maybe the symbol) of the attribute. Motherfucker. Thanks a lot.
|
# ? Dec 7, 2007 10:35 |
|
code:
|
# ? Dec 7, 2007 12:09 |
Sharrow posted:
God, I cannot wait to start playing around with Rails 2.0. I just have to make it through finals week first This blog post from the Ruby on Rails blog shows a lot of the work that's been pushed into the newest release, and it all sounds really exciting.
|
|
# ? Dec 7, 2007 14:59 |
|
Seems like they found a last minute blocker. It's going to be 2.0.1.
|
# ? Dec 7, 2007 15:24 |
|
shopvac4christ posted:This blog post This looks neat. I like this part, it may help with my problem. quote:Action Pack: Exception handling I like to keep things as tidy as possible.
|
# ? Dec 8, 2007 00:09 |
|
What's the best way to get Ruby installed on Windows XP? Last time, I tried the one-click installer, but that installed a bunch of crap I don't want and couldn't unselect (some IDE, if I recall correctly, and some other stuff that was hard to remove). I tried just downloading the plain Ruby 1.8.6 binary from ruby-lang.org, which seemed promising, but it turns out that that's missing lots of DLLs that are required by RubyGems and other such things. Do I have to use the one-click installer, or is there a better option?
|
# ? Dec 9, 2007 22:16 |
|
rolocroz posted:What's the best way to get Ruby installed on Windows XP? Last time, I tried the one-click installer, but that installed a bunch of crap I don't want and couldn't unselect (some IDE, if I recall correctly, and some other stuff that was hard to remove). I tried just downloading the plain Ruby 1.8.6 binary from ruby-lang.org, which seemed promising, but it turns out that that's missing lots of DLLs that are required by RubyGems and other such things. Do I have to use the one-click installer, or is there a better option? You couldn't unselect ScITE? That's the only unnecessary thing it installs, if I recall correctly, and you can opt out of it.
|
# ? Dec 10, 2007 00:08 |
|
|
# ? Apr 23, 2024 13:25 |
|
I was about to say InstantRails, but I went to it's website and apparently it has been replaced by BitNami. Has anyone here done batch/multiple file upload within a rails application before?
|
# ? Dec 10, 2007 00:10 |