|
will_paginate itself is a Module and it extends ActiveRecord::Base directly. We generally don't do that anymore. https://github.com/mislav/will_paginate/blob/master/lib/will_paginate.rb
|
# ? Jan 31, 2011 13:14 |
|
|
# ? Apr 18, 2024 01:24 |
|
This is the solution I've settled on, attached if anyone is interested. I've decided to paginate in the view and it turns out that works great. http://pastie.org/1514717
|
# ? Jan 31, 2011 15:14 |
|
.
maskenfreiheit fucked around with this message at 21:32 on Apr 28, 2019 |
# ? Jan 31, 2011 22:04 |
|
GregNorc posted:So I need to crawl some websites with an actual full fledged web browser. (Looking at stuff related to cookies, and flash, so wget or curl would not suffice) Fake?
|
# ? Jan 31, 2011 22:10 |
|
GregNorc posted:So I need to crawl some websites with an actual full fledged web browser. (Looking at stuff related to cookies, and flash, so wget or curl would not suffice) Sounds like Selenium might be a good fit for this.
|
# ? Jan 31, 2011 22:18 |
|
.
maskenfreiheit fucked around with this message at 21:32 on Apr 28, 2019 |
# ? Jan 31, 2011 22:52 |
|
The RSpec Book has a bunch of chapters on using cucumber/webrat/selenium to test views in Rails. It's a great place to start, although I don't know with certainty if they will let you test what you need.
|
# ? Jan 31, 2011 23:32 |
|
How does Rails 3 Way compare to the Pragmatic Programmer's Agile series? I have a good understanding of basic Rails concepts but get a little lost when I actually try to put code into action.
|
# ? Feb 1, 2011 18:55 |
|
gce posted:How does Rails 3 Way compare to the Pragmatic Programmer's Agile series? I have a good understanding of basic Rails concepts but get a little lost when I actually try to put code into action.
|
# ? Feb 1, 2011 19:09 |
|
Not perfectly on-topic, but I figure a lot of people would know the answer to this: In textmate, is there a way to auto-insert a closing 'end' when I open a block? I know I have snippets for things like "def[tab]", which will insert a closing 'end' and a blank line in between. But TM clearly knows when I open a block, by increasing indentation, and when I end a block, by decreasing indentation. Is there a way to make it auto-insert the code for the end of the block?
|
# ? Feb 1, 2011 22:48 |
|
do[tab]
|
# ? Feb 1, 2011 22:58 |
|
NotShadowStar posted:do[tab] Plus, there are blocks (using the general use of the term rather than specific Ruby do/end blocks) that TM doesn't have snippets for. For example, Cucumber "Scenario: " blocks, which are ended with a line containing the same indentation as the start of the block (which is a whole other problem right there.)
|
# ? Feb 1, 2011 23:15 |
|
comedy switch-to-vim-and-use-endwise response
|
# ? Feb 1, 2011 23:49 |
|
Magicmat posted:Yeah, but is there a way to do that without snippets, like TM does with parentheses or quotes? The problem with snippets is that, a), I need to retrain my fingers to use tab instead of return and, b), the snippet isn't always what I want. For example, with 'do', it always has a "|variable|" statement after the "do". I can just backspace over this, but that's still an extra keystroke and branch in my thought pattern that I'd rather not have. Auto-indent doesn't work by looking at if you're in a block, it works by comparing the line you just hit return from and see if it should match indentation or not. That's it. Textmate doesn't know or care if you're in our out of parentheses, it just auto-inserts or deletes matching ones. Textmate doesn't automatically do this because sometimes you want do |f|; yield; end; and sometimes you want {|f| yield }. If it really bugs you, you can always use {|f| } and drive anyone who's working on your code bonkers. Oh and don't get me started on Vim's indentation. I can't fully switch to Vim because the HTML and PHP indentation is completely useless. Oh sure there's always 'but you can fix it yourself!' but I don't know that much about Vim internally and I'm spending too much of my life fixing other people's crap anyway.
|
# ? Feb 1, 2011 23:55 |
|
Pardot posted:comedy switch-to-vim-and-use-endwise response edit: A bit sad, it does not do proper indentation. Obsurveyor fucked around with this message at 02:11 on Feb 3, 2011 |
# ? Feb 1, 2011 23:56 |
|
Pardot posted:comedy switch-to-vim-and-use-endwise response Sorry but I not only paid more ONLY to use textmate, but it's also the only reason I am using a mac.
|
# ? Feb 3, 2011 02:09 |
|
Nolgthorn posted:Sorry but I not only paid more ONLY to use textmate, but it's also the only reason I am using a mac. Yea, I use a mac with textmate at work and its great. Redcar for linux is a decent textmate clone for the linux users. Soooooo flash messages, how the gently caress do they work? Do I pass messages in via controller? Because thats what I thought the :message method in my validations was for. I want my error messages to be as specific as possible.
|
# ? Feb 3, 2011 15:46 |
|
rugbert posted:Soooooo flash messages, how the gently caress do they work? Do I pass messages in via controller? It is a good way to pass info between pages during a redirect, such as a message stating that the record was successfully created. You typically wouldn't use it to display validation error messages as the standard procedure, and easiest method, is to redisplay the form on the same action handling the model validation - giving full access to the model object. And yes, the controller is the usual place to set your flash values.
|
# ? Feb 3, 2011 16:51 |
|
Well this is a big shame: http://netbeans.org/community/news/show/1507.html?utm_source=netbeans&utm_campaign=welcomepage I absolutely love the Ruby integration in Netbeans. This is heartbreaking. I know that Ruby and Rails don't necessarily really need an IDE but Netbeans has made a lot of day to day tasks like managing project files, committing code, and generating things a lot quicker. Anyone have any suggestions on a good Ruby centric IDE that plays nice on Mac?
|
# ? Feb 4, 2011 16:33 |
|
It depends on what you want out of an IDE. I know there's LOL VIM LOL, and myself for many years I couldn't bring myself to do it. But with this and this saying exactly how I felt about it, and Yehuda's Janus addins to MacVim, VIM really has been nice so far if you're working in strictly Ruby land. This screencast/lecture also really helped me get into the mindset, and the person who is running Vimcasts is writing a book; so that should be awesome. Be warned that outside of Ruby land Vim gets crappy. PHP or bare HTML is really, really frustrating. I get the impression that the Ruby community is just like the gay community, move into somewhere that's dank and needs repair (Vim, Java, Web development etc.), make everything awesome and move on.
|
# ? Feb 4, 2011 16:46 |
|
NotShadowStar posted:Be warned that outside of Ruby land Vim gets crappy. PHP or bare HTML is really, really frustrating. I get the impression that the Ruby community is just like the gay community, move into somewhere that's dank and needs repair (Vim, Java, Web development etc.), make everything awesome and move on. Yesterday I spent an hour trying to get my favorite mapping ever to work properly when it turned out to be an issue with putty and vim. I had to write: code:
|
# ? Feb 5, 2011 17:59 |
|
Ok, so Im trying to display all new tattoos on this site's home page and set it up so clicking on said tattoo takes you to the artist's page. my models are set up as User has_many Tattoos with the Tattoo table relating to users with a user_id field. I thought I could try this: code:
code:
|
# ? Feb 11, 2011 17:50 |
|
For rails 3:code:
Rails 2: code:
dustgun fucked around with this message at 18:15 on Feb 11, 2011 |
# ? Feb 11, 2011 18:13 |
|
A silly question from a new Ruby & Rails user: I'm trying to install RubyOSX 1.2 to my Powerbook with Tiger, and everything goes fine until I attempt to update RubyGems. The RubyonRails Wiki tells me to type the following into Terminal: $ sudo gem install rubygems-update $ sudo update_rubygems ... which I do, but both of these return the following error message: "ERROR: While executing gem ... (Gem::RemoteSourceException) HTTP Response 302" I've searched until how to fix this, and have tried to update RubyGems, but even then I'm still getting problems. I've tried to install Gems from scratch, but cannot figure out how to run ruby setup.rb from Terminal. (Note: I haven't used Terminal in a long time and recognize that I'm likely missing something quite simple here.) Can anyone offer suggestions on how to proceed from here?
|
# ? Feb 12, 2011 12:35 |
|
TunanFish posted:RubyOSX Undo everything you did and use RVM instead.
|
# ? Feb 12, 2011 14:43 |
|
NotShadowStar posted:RVM Thanks for the tip. It's going well thus far, but as I'm just beginning to set things with a "rails server" command inside the directory I'm working in, I get the following error: "Could not find gem 'sqlite3 (>= 0, runtime)' in any of the gem sources listed in your Gemfile." I've looked around on a number of forums for help with this, but haven't found a solution that resolves the problem. I'm running Ruby 1.9.2 and gems -v gives me '1.5.0' Sorry for a n00bish question again!
|
# ? Feb 12, 2011 18:18 |
|
'gem install bundler' and 'bundle install' in your Rails directory.
|
# ? Feb 12, 2011 18:51 |
|
There now appear to be two related problems. First, when I try bundle install, I get this: 'Installing sqlite3 (1.3.3) with native extensions /Users/mary/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:529:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /Users/mary/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb checking for sqlite3.h... yes checking for sqlite3_libversion_number() in -lsqlite3... yes checking for rb_proc_arity()... yes checking for sqlite3_initialize()... no sqlite3-ruby only supports sqlite3 versions 3.6.16+, please upgrade!' Then, as a result, when I attempt to do 'rails server,' I get this: Could not find gem 'sqlite3 (>= 0, runtime)' in any of the gem sources listed in your Gemfile. Currently, I have SQLite 3.4.0, but can't figure out how to update it. Thanks!
|
# ? Feb 12, 2011 19:25 |
|
Could be path conflicts. Check that your old ruby and gems files in /usr/bin are deleted, and that your paths are updated in your ~/.profile and apache conf file.
|
# ? Feb 12, 2011 21:15 |
|
Also be sure to read the RVM documentation very, very carefully, in particular what it says on adding a line to your .bash_profile. Though on the other hand the sqlite3 libraries available on Tiger could be very old. In that case, install Homebrew and then do 'brew install sqlite'. Also your PPC Powerbook is reaching the end of the line, especially when 10.7 is out. Your best hope is Leopard but it's a slow beast. Something to consider if you're going to be doing future development work in OSX.
|
# ? Feb 12, 2011 22:34 |
|
NotShadowStar posted:In that case, install Homebrew and then do 'brew install sqlite'. Unless the Tiger fork is more robust than I remember, brew is Leopard and up Seconding the point that a PPC Mac is...really not very feasible for modern development. You can almost definitely pick up an early Intel system for cheapish nowadays...
|
# ? Feb 13, 2011 05:09 |
|
Thanks for all of the advice! I made a typo up above, so I'm not quite as backwards as I indicated - I'm using a MacBook Pro circa 2006, so it's an Intel processor. After reading these replies and looking at various other sources, it seems like life is going to be difficult doing any development work without 10.6, so I'm thinking of upgrading ASAP and perhaps getting a RAM upgrade to boot. In your opinion, does that make sense - go to 10.6, install Homebrew, and go from there?
|
# ? Feb 13, 2011 14:31 |
|
Ah you said Powerbook and were talking about Tiger so all signs pointed to a PPC Powerbook. Snow Leopard is $30 and will be supported for quite a while, so it's very worth it. When you do upgrade, don't do an upgrade or archive and install, just back up what you need before and erase and install.
|
# ? Feb 13, 2011 15:31 |
|
dustgun posted:For rails 3: Oh cool thanks! Is there a good Add This gem or something? I tried adding the add this code to my posts but when you click it, it likes the current page and not the current post :/
|
# ? Feb 14, 2011 23:26 |
|
Sorry for yet more stupid questions, but I'm still running into the same problems with 10.6 installed (on an Intel MacBook Pro). Can someone point me to a walkthrough for installing Rails that starts from zero? I have attempted both to download RVM from: ttp://rvm.beginrescueend.com/releases/rvm-install-head but do not have Git, and cannot seem to install it properly, and the manual instruction steps are not working, even after adjusting the .bash_profile. Sorry for obnoxious questions - I just feel like attempting to install Rails, which seemed so simple, has already consumed several hours. I'm just looking for a simple walkthrough -- following the steps with RVM and those on the Rails website has not led it to function.
|
# ? Feb 14, 2011 23:56 |
|
Install homebrew, then 'brew install git'. Developer tools, as always, needs to be installed. (Rails is actually built in OSX > 10.5, but it's old and you should be using Ruby 1.9.2 anyway)
|
# ? Feb 15, 2011 02:57 |
|
rugbert posted:Oh cool thanks!
|
# ? Feb 15, 2011 05:43 |
|
I get multiple error messages when I attempt to install Homebrew: 1. Warning: Xcode is not installed! Builds may fail! (I downloaded and installed the latest version of Xcode from Mac Developer Tools while still running 10.4, so I'm not sure where this is coming from.) 2. Warning: It appears you have MacPorts or Fink installed. (I try to uninstall Macports using the following instructions [http://guide.macports.org/#installing.macports.uninstalling], but it tells me 'no suitable image found.' and quits.) 3. Error: Failure while executing: ./configure --disable-debug --prefix=/usr/local/Cellar/wget/1.12 --disable-iri 'It looks like an autotools configure failed.'
|
# ? Feb 15, 2011 10:23 |
|
dustgun posted:Can you post the code you're using? Its just the code supplied from addthis.com. code:
|
# ? Feb 15, 2011 13:05 |
|
|
# ? Apr 18, 2024 01:24 |
|
I'm having some trouble with Nokogiri. I have a HTML::Builder to create a new HTML document, and inside it I'm looping over a collection with the #each method. Basically, if the current loop item has some attribute, create a new div in the document to contain some HTML, and have that div contain all subsequent loops' HTML until we hit another loop item that fulfills our requirements, where we create another div, etc. Hard to explain, but imagine I have the following array of array: code:
code:
code:
Edit: If anybody cares, I figured it out. container_node = doc.div always returns the NodeBuilder object that was just used to add a node to your document. NodeBuilders are pretty useless and I have no idea why they are returned; they're an internal Nokogiri class used mainly to set attributes on the new node (so things like foo.div.my_css_class_name work) and setup child blocks (which I guess answers my question.) However, if you do code:
Also, stay away from using XPath and, worse, CSS selectors in Nokogiri if speed is a concern -- they're horrendously slow. I mean, Nokogiri is probably a lot faster than other Ruby alternatives, but still, I literally sped my application up by almost 4x by refactoring the code to walk the DOM manually rather than using selectors. Of course, the trade-off is that the code is a lot more fragile now (if the document structure I'm parsing changes even a bit, it stops working) but it was worth it for me. I used to do 2-3 CSS selects a loop iteration, times 50 iterations per file (on average), times 500 files -- it took 120 seconds; now it takes about 30 sec. Magicmat fucked around with this message at 13:38 on Feb 16, 2011 |
# ? Feb 15, 2011 14:16 |