|
Check out that Rails for Zombies site I linked, it's supposed to be really good for beginners. Bump this thread if you have any other questions, I'll keep an eye on it.
|
# ? Feb 2, 2012 03:14 |
|
|
# ? May 15, 2024 04:21 |
|
someone posted:
Dudes: Stop writing "self"! (Also "return") You should be writing code like this: code:
|
# ? Feb 2, 2012 17:25 |
|
I know, I mentioned that above my code block. I wrote the example that way because the Ruby style would be a little confusing for someone who is new to Ruby. Adding the self and return hopefully made it clearer in the example but I would never write real code like that.
|
# ? Feb 2, 2012 17:43 |
|
For those of you that are very familiar with Inherited Resources, I'm having a problem modeling the following association chain in my controllers: Say I have Users which belong to many Leagues and each user has a single Team for a particular league. The league is identified by a slug as the subdomain, and since there is only a single team for a particular user and league, I don't need to identify that either. So instead of a URL that looks like http://example.com/leagues/1/teams/1, I get http://myleague.example.com/team, which looks a hell of a lot better to me. The problem I ran into with Inherited Resources is describing the relationship between a league (identified by the slug in the subdomain), the logged in user, and a team singleton using its idioms for describing the associations without having to resort to hacky poo poo like before_filter hooks and injecting ID attributes in the params hash. It really seems that something like this would work: code:
|
# ? Feb 2, 2012 17:57 |
|
Hi! I've had a bitnami redmine 1.0.2 stack running for about a year. It came with... ruby 1.8.7 rails 2.3.9 rack 1.0.1 Now I want to bring redmine up to date, to version 1.3.0. http://www.redmine.org/projects/redmine/wiki/RedmineInstall tells me 1.3.x requires... ruby 1.8.7 rails 2.3.14 rack 1.1.x So I can't just replace the application files, I'd also need to update rails and rack. So it's probably in my interest to use a fresh bitnami redmine 1.3.0 stack because it will come with all the necessary dependencies, none of which I have any experience using and/or keeping up to date (which was the point of using a bitnami stack in the first place). But if I just back up the database / conf files / uploaded files, uninstall the 1.0.2 stack, and install the 1.3.0 stack, the database schema will be different, so I won't likely be able to just use the old database. How do I do this? epswing fucked around with this message at 18:29 on Feb 2, 2012 |
# ? Feb 2, 2012 18:19 |
|
code:
|
# ? Feb 3, 2012 21:47 |
|
Physical posted:
Base is the class' name, ActiveRecord is the module or package, :: is the namespace operator.
|
# ? Feb 3, 2012 22:01 |
|
Here's a non-rails longshot: Anyone have experience with Shoes, the graphical app builder built on Ruby? I'm trying to build an app where the (very simple) UI changes modes a few times as the program runs; what's the most sensible way to program this? e: To make this a little clearer, I'd like the program to first have a mode where it displays some instructions in a text box; then those disappear and other controls appear after the user does something; then the user does something else and some other controls appear. Is it even possible to delete graphics items in a Shoes app? Vivian Darkbloom fucked around with this message at 09:31 on Feb 4, 2012 |
# ? Feb 4, 2012 09:26 |
|
It's been a while since I've played with Shoes, but everything has show/hide/toggle methods for visibility and a remove method. Slots also have a clear method to remove their contents. The manual covers all that and more.
|
# ? Feb 4, 2012 11:12 |
|
Soup in a Bag posted:It's been a while since I've played with Shoes, but everything has show/hide/toggle methods for visibility and a remove method. Slots also have a clear method to remove their contents. The manual covers all that and more. Oh, good. Guess I overlooked those options. I think what was really blowing my mind with Shoes is that it seems to run every Shoes command all at once, so you can't do this, for instance: code:
|
# ? Feb 4, 2012 23:17 |
|
Another Shoes question! When I first coded the following, I expected it to have two steps: first, the instructions display; then after hitting the spacebar the task displays. Instead, both display at once.code:
|
# ? Feb 9, 2012 06:43 |
|
whats the best tutorials that don't focus on scaffolding? it seems like 90% of the ruby tutorials focus on running 3 commands and VOILA you got a blog. just while im getting started id like to get walked through ultimately what the scaffolding does, since it spits out tons of garbage files each time and i get lost in the weeds trying to reconstruct it all
|
# ? Feb 11, 2012 14:41 |
|
The official Rails guides are just fine for that. Just ignore the "Getting Started with Rails" (or skim through it) tutorial and concentrate on the ones that focus on models, controllers/routing and views.
|
# ? Feb 11, 2012 14:50 |
|
I think Railstutorial.org starts with scaffolds, but quickly abandons them and starts over within a chapter. It's also an awesome tutorial, and there was just a new version released.
|
# ? Feb 11, 2012 15:00 |
|
I made the bad decision to begin my Rails app with Disqus comments. I figured it would be easy to export them when I outgrew the simple stop-gap solution it provided. I know how it's organized, but I'm having trouble figuring out a simple way of parsing all the entries. The XML file is basically set up like this: pre:<thread dsq:id="12345"> <id>foo</id> </thread> then, much further down the same XML file pre:<post id="177002220"> <id/> <message><![CDATA[This is my awesome comment!]]></message> <createdAt>2011-04-02T19:02:04Z</createdAt> <author> <email>me@example.com</email> <name>myname</name> <isAnonymous/> </author> <ipAddress>192.168.1.1</ipAddress> <thread dsq:id="12345"/> </post> This is what I have, but it just hangs. Am I even close? pre:require 'nokogiri' @doc = Nokogiri::XML(File.open("~/Downloads/disqus.xml")) @doc.css("thread").each do |t| @t = t @thread_id = t.attributes["id"].value @doc.css("post").each do |p| @p = p @post_id = p.attributes["id"].value end if @thread_id == @post_id c = Comment.new c.code = @t.css("id").text c.author = @p.css("author name").text c.contents = @p.css("message").text c.save! end end plasticbugs fucked around with this message at 06:08 on Feb 12, 2012 |
# ? Feb 12, 2012 06:04 |
|
plasticbugs posted:I basically need to parse through all the "threads", and for each unique thread ID, I need to search across all the "posts" in the XML to find all the entries that share that "thread id". Then, save out a Comment for the matching data. There isn't much of a reason to separate out the threads and comments loops, just go for it all in one shot. I've never used css selectors for XML node traversal, so I'd honestly just go for basic XPath. pre:require 'nokogiri' doc = Nokogiri::XML(File.open(File.join(Dir.home(), "Downloads", "disqus.xml"))) doc.xpath('/xmlns:disqus/xmlns:thread').each do |t| doc.xpath(%Q<//xmlns:post[xmlns:thread[@dsq:id="#{t.attr('id')}"]]>).each do |c| comment = Comment.new comment.code = t.attr('id') comment.author = c.xpath('xmlns:author/xmlns:name').inner_text() comment.message = c.xpath('xmlns:message').inner_text() comment.save! end end Long story short, @thread_id and @post_id in your script are never going to be the same. UxP fucked around with this message at 18:07 on Feb 12, 2012 |
# ? Feb 12, 2012 07:50 |
|
UxP posted:There isn't much of a reason to separate out the threads and comments loops, just go for it all in one shot. I've never used css selectors for XML node traversal, so I'd honestly just go for basic XPath. Thanks so much for your help! This worked. I get in over my head quickly and this is an instance where I should go back to basics for a little while and learn more Ruby and less Rails. I also need to look into xpath, as it seems to be more powerful than using just CSS to traverse the hierarchy. EDIT: Can you or anyone recommend a good book or site to learn more about working with XML with Ruby or any other non C language? Originally I had it scoped with locals, but when that didn't work, I tried it the other way with all instance variables thinking maybe the first block wasn't passing variables into the next block. Me code pretty one day. plasticbugs fucked around with this message at 20:23 on Feb 12, 2012 |
# ? Feb 12, 2012 20:14 |
|
I would really like to use Eclipse for RoR development. I found Apana's RadRails but no current tutorials. And the syntax highlighting doesn't work. This is really important to me, having proper syntax highlighting. Has anyone got some current or working tutorials of Eclipse and RoR or Apana's radrails? Here are some of the links I've used but they are all old and none of the screens match up and I can't even find where to put the path to the ruby interpreter. http://www.ibm.com/developerworks/opensource/library/os-rubyeclipse/ http://napcs.com/howto/railsonwindows.html http://oldwiki.rubyonrails.org/rails/pages/HowToUseEclipseForRailsDevelopment
|
# ? Feb 14, 2012 20:58 |
|
Hi Rails people! I'm going to be picking up RoR soon for my job. Does anyone have any recommended tutorials that are focused on someone who has plenty of experience under their belt? I'll be moving from a mostly Python/Django environment, if that helps. So I'm comfortable with MVC, ORMs, etc. Sorry if this has been asked before. I tried to look through the thread but it's kinda massive...
|
# ? Feb 16, 2012 16:19 |
|
Kim Jong III posted:Hi Rails people! I'm going to be picking up RoR soon for my job. Does anyone have any recommended tutorials that are focused on someone who has plenty of experience under their belt? The Rails 3 Way seems to be the de facto encyclopedia on rails. Its not really a tutorial but will cover everything at a fairly in-depth level since you are already familiar with MVC etc.
|
# ? Feb 16, 2012 19:05 |
|
Kim Jong III posted:Hi Rails people! I'm going to be picking up RoR soon for my job. Does anyone have any recommended tutorials that are focused on someone who has plenty of experience under their belt? http://ruby.railstutorial.org/ruby-on-rails-tutorial-book Pragmatic has a good book but the latest version is a skinny shell of it's former self: http://pragprog.com/book/rails4/agile-web-development-with-rails
|
# ? Feb 16, 2012 19:17 |
|
Kim Jong III posted:I'll be moving from a mostly Python/Django environment, if that helps. So I'm comfortable with MVC, ORMs, The responsibilities of the M V and C in django do not line up with the M V and C in rails, so figure out the differences before you get super confused.
|
# ? Feb 16, 2012 19:19 |
|
Pardot posted:The responsibilities of the M V and C in django do not line up with the M V and C in rails, so figure out the differences before you get super confused. Rails MVC: M: all business logic V: templates (erb and haml) C: turning GET and POST parameters into calls into model methods, turning models into JSON/XML/template renders
|
# ? Feb 16, 2012 20:02 |
|
Is there a good way to make action caching worth with multiple formats? As far as I can tell, Rails doesn't seem to care about the Accept header when determining cache keys, so when I enable action caching, Rails will always return the response to the first format that was requested (all formats will have the same cache key). There is a :cache_path parameter, but I'm not sure what would be the recommended way to use it in this case, or if it helps at all.
|
# ? Feb 16, 2012 23:05 |
|
What's your favorite GUI toolkit? Shoes is kind of a mess, despite how clever and Ruby-ish it can be, and I find it very hard to control. I don't care if it's ugly, so I'm leaning towards Ruby Tk because it looks relatively easy and well documented.
|
# ? Feb 17, 2012 00:08 |
|
Vivian Darkbloom posted:What's your favorite GUI toolkit? Shoes is kind of a mess, despite how clever and Ruby-ish it can be, and I find it very hard to control. I don't care if it's ugly, so I'm leaning towards Ruby Tk because it looks relatively easy and well documented.
|
# ? Feb 17, 2012 04:34 |
|
BonzoESC posted:Rails with bootstrap, and tell the client to htfu and accept that http is the future. I'm just a grad student writing behavioral experiments, no clients except a mob of bored undergrads.
|
# ? Feb 17, 2012 05:27 |
|
enki42 posted:I think Railstutorial.org starts with scaffolds, but quickly abandons them and starts over within a chapter. It's also an awesome tutorial, and there was just a new version released. awesome, i can't believe i dismissed this one before. finally a tutorial that i'm really clicking with. good stuff.
|
# ? Feb 18, 2012 02:10 |
|
so who's heading to Austin this april?
|
# ? Feb 20, 2012 20:27 |
|
Smol posted:Is there a good way to make action caching worth with multiple formats? As far as I can tell, Rails doesn't seem to care about the Accept header when determining cache keys, so when I enable action caching, Rails will always return the response to the first format that was requested (all formats will have the same cache key). With Action Caching it should just work out of the box, e.g. cache JSON separately from HTML or XML. With Page Caching I have no idea what would happen, but you probably don't want page caching...
|
# ? Feb 21, 2012 01:00 |
|
I'm playing around with sorting a list of products, and need some help. After following Ryan Bates HABTM tutorial I now have products that can belong to a number of categories. I now want to filter products by their category specified by the user. Can someone give me an example or hints on how to do this?
|
# ? Feb 21, 2012 20:55 |
|
It might be a good idea to use nested resources for that. Here's a screencast about it: http://railscasts.com/episodes/139-nested-resources
|
# ? Feb 21, 2012 22:12 |
|
Ok, I'm crying uncle: How do I get rid of pages and pages of code:
dustgun fucked around with this message at 03:25 on Feb 23, 2012 |
# ? Feb 23, 2012 03:22 |
|
Why do you want to get rid of them? It's useful to have access logs. Logs are streams.
|
# ? Feb 23, 2012 03:26 |
|
I think I read on Github or Stack Overflow that suppressing the asset log messages is an option that's coming soon.
|
# ? Feb 23, 2012 03:31 |
I'm ready to kill myself. Okay not really but my friend/frontend dev guy did a pull request today where he basically rewrote our entire landing page, started using compass / blueprint, and now I'm running into problems with the asset pipeline deploying to heroku. It's gotten to the point where I'm ready to scrap the whole thing and redo it in Sinatra. Also I'm a little hung over because I got day-drunk at lunch, but still. Can anyone point me to info on the stylesheet link tree? I think that's where the problem is, like it's not precompiling a few stylesheets because they aren't in the tree or something. Here's what my log looks like:code:
|
|
# ? Feb 23, 2012 03:37 |
|
Pardot posted:Why do you want to get rid of them? It's useful to have access logs. Logs are streams. That came out a bit bitchier than I wanted. Sorry. prom candy posted:I think I read on Github or Stack Overflow that suppressing the asset log messages is an option that's coming soon. code:
|
# ? Feb 23, 2012 03:44 |
|
A MIRACLE posted:I'm ready to kill myself. Okay not really but my friend/frontend dev guy did a pull request today where he basically rewrote our entire landing page, started using compass / blueprint, and now I'm running into problems with the asset pipeline deploying to heroku. It's gotten to the point where I'm ready to scrap the whole thing and redo it in Sinatra. Also I'm a little hung over because I got day-drunk at lunch, but still. Can anyone point me to info on the stylesheet link tree? I think that's where the problem is, like it's not precompiling a few stylesheets because they aren't in the tree or something. Here's what my log looks like: If you're including an asset directly in a template that's not called application.js.*, application.css.*, or is not an image Rails won't automatically precompile it in production. You either need to require screen.css from application.css, or you need to add it to your list of precompiles in production.rb code:
|
# ? Feb 23, 2012 15:17 |
|
prom candy posted:Edit: The asset pipeline is full of gotchas, make sure you read the documentation on it or it's going to drive you nuts. I speak from experience. Just one that note: When we did the asset pipeline here we ended up creating a few different directories in the stylsheets folder and putting a directoryname.css.erb in each one along with the other stylesheets that just had this in it: *= require_self *= require_tree . This was for the different distinct sections of our site like admin, public, team, etc. Then we added it to the precompile line. We're pretty happy with the results. The asset pipeline is a complete bastard but I can't argue with the results. According to newrelic it dropped our page load times significantly.
|
# ? Feb 23, 2012 15:42 |
|
|
# ? May 15, 2024 04:21 |
|
Kim Jong III posted:Hi Rails people! I'm going to be picking up RoR soon for my job. Does anyone have any recommended tutorials that are focused on someone who has plenty of experience under their belt? If you're going to be using ActiveRecord as your ORM, I highly suggest using Squeel. The AR query methods aren't completely horrible, but get verbose very quickly. If you're doing the "skinny controller, fat model" thing, it'll make the sea of scopes you'll invariably end up with 100 times more readable, and up much less space. To make your stay at Rails more pleasant, check out these guys' projects on Github to see if there's anything you might want to use: https://github.com/plataformatec https://github.com/josevalim https://github.com/collectiveidea I personally wouldn't fly without inherited resources, has_scope, and responders again, namely. Coming into Rails, I was initially depressed by how much code repetition there was in controllers.
|
# ? Feb 23, 2012 15:47 |