|
stack posted:What is a better way to default to a value in an erb file? I might put some of that code into a helper. Either way, you can use a ternary operator: code:
|
# ? Apr 21, 2010 21:36 |
|
|
# ? Apr 24, 2024 15:57 |
|
I answered that question on stackoverflow.com not that long ago. There's also some additional interesting conversation. http://stackoverflow.com/questions/2060561/optional-local-variables-in-rails-partial-templates-how-do-i-get-out-of-the-def
|
# ? Apr 21, 2010 22:12 |
|
jonnii posted:I answered that question on stackoverflow.com not that long ago. There's also some additional interesting conversation. Thanks! I clicked around on stack overflow a bunch but missed this one.
|
# ? Apr 21, 2010 23:25 |
|
dizzywhip fucked around with this message at 21:54 on Nov 9, 2020 |
# ? May 7, 2010 20:06 |
|
Whatever you're doing it sounds like a bad idea and unnecessary complexity. The only thing I can think of is leveraging the DB itself so it'll be DB-type specific. For instance with MySQL:code:
|
# ? May 7, 2010 21:33 |
|
dizzywhip fucked around with this message at 21:54 on Nov 9, 2020 |
# ? May 8, 2010 08:25 |
|
What about :code:
|
# ? May 8, 2010 16:14 |
|
Or write your own User#name= method that downcases all the usernames before they're added to the database. I havent tested it out, but code:
edit: nah that wouldn't do it when you're doing update_attributes, so you'll probably have to make a before_save callback. Pardot fucked around with this message at 16:22 on May 8, 2010 |
# ? May 8, 2010 16:19 |
|
You have a few options.code:
code:
code:
|
# ? May 8, 2010 16:22 |
|
dizzywhip fucked around with this message at 21:54 on Nov 9, 2020 |
# ? May 8, 2010 18:20 |
|
skidooer posted:
I had no idea about the method_chain, that's awesome.
|
# ? May 8, 2010 18:43 |
|
Ryouga Inverse posted:I had no idea about the method_chain, that's awesome. Treat it like a loaded gun. And don't go crazy with it. Please.
|
# ? May 8, 2010 20:22 |
|
manero posted:Treat it like a loaded gun. And don't go crazy with it. Please. Yehuda Katz is, as always, the voice of reason http://yehudakatz.com/2009/03/06/alias_method_chain-in-models/
|
# ? May 8, 2010 23:00 |
|
mit_senf posted:I think the syntax
|
# ? May 9, 2010 00:48 |
|
I wanted to post this because I figured it out the other day and it's pretty cool. I've been using rvm for development lately and different gemsets for each project. It gets to be cumbersome to switch gemsets and versions each time you go in to a project. Rvm supports config files in the form of .rvmrc per project and can be set to automatically change ruby versions. The syntax is as follows:code:
|
# ? May 15, 2010 16:20 |
|
RVM is great, I've found it to be a passable analogue to Python's virtualenv. It's still kinda flaky in spots, mostly just that the invocation syntax is clunky, but it does work. I used to stay on Ruby 1.8.6 because it has the strongest OS-level support, but since discovering RVM I've been more apt to play with 1.8.7 and all its new shinies, at least for non-server-oriented projects. (Haven't yet looked into how to integrate it with eg Passenger. I assume it can, just like how mod-wsgi Web apps can leverage virtualenv in the Python world, but haven't verified this.) Combined with Bundler it makes setting up per-project environments and gemsets pretty easy. No more worrying about an enormous list of global gems stomping all over each other.
|
# ? May 15, 2010 19:20 |
|
bitprophet posted:RVM is great, I've found it to be a passable analogue to Python's virtualenv. It's still kinda flaky in spots, mostly just that the invocation syntax is clunky, but it does work. http://rvm.beginrescueend.com/integration/passenger/ I used the same passenger_ruby script for a CGI app. Change #!/usr/bin/env ruby to #!~/.rvm/bin/passenger_ruby and you're all set. There's very little reason to use 1.8 anymore. If there's an abandoned library that won't work on 1.8 I'll try and fix it, I've done that a lot already.
|
# ? May 15, 2010 20:44 |
|
NotShadowStar posted:There's very little reason to use 1.8 anymore. (Thanks for the confirmation re: Passenger.) 1.9 is still way too new for serious deployment IMO, certainly at any outfit which has to maintain codebases that are more than a year or two old, and/or which deploys to servers not running on the bleeding edge. And since I tend to not like bouncing between various different versions of X often (where X is a language or a program or OS) I tend to try and pick something that's old enough to be stable and readily available but not SO old that it lacks any feature parity whatsoever. Thus, 1.8.7 fits the bill pretty handily. (The Web stuff at my job is all still 1.8.6; for us, moving to that version's REE is considered a big step, even. We don't have much manpower available for R&D or support, otherwise we probably would've moved to 1.8.7 by now. Meh.) bitprophet fucked around with this message at 23:45 on May 15, 2010 |
# ? May 15, 2010 23:42 |
|
One of the way cool features about rvm is you can run a single command against all installed versions of Ruby. For example: your test suite:code:
|
# ? May 16, 2010 02:37 |
|
bitprophet posted:1.9 is still way too new for serious deployment IMO, certainly at any outfit which has to maintain codebases that are more than a year or two old, and/or which deploys to servers not running on the bleeding edge. I disagree. I've been running 1.9.1 in production for well over a year on a codebase that's 4 years old. The upgrade took maybe 3 days of work and resulted in a huge speed improvement (average of 2x as fast).
|
# ? May 31, 2010 00:29 |
|
So who else is headed out to Baltimore?
|
# ? May 31, 2010 04:34 |
|
Evil Trout posted:I disagree. I've been running 1.9.1 in production for well over a year on a codebase that's 4 years old. The upgrade took maybe 3 days of work and resulted in a huge speed improvement (average of 2x as fast).
|
# ? May 31, 2010 04:44 |
|
Obsurveyor posted:The thing that pisses me off is that they broke support for 1.9.1 in Rails 3. I am happy running 1.9.1 but I am not happy having to use 1.9.2-trunk. They were targeting the Rails 3 release for this Baltimore conference and I do not know if that has changed but if it goes release with this 1.9.2 requirement, I am going to be extremely annoyed. Wait what? I've been running Rails 3 on 1.9.1 since like December and have had nary a problem. I tried 1.9.2 the other week and things were horribly broken, WEBRick wouldn't even start on an empty Rails project.
|
# ? May 31, 2010 17:54 |
|
Pardot posted:So who else is headed out to Baltimore?
|
# ? May 31, 2010 18:31 |
|
dustgun posted:Based there, but probably only going to Bohconf. I'm planning that for the tutorials day dustgun posted:Have fun getting murdered, suckers.
|
# ? May 31, 2010 18:32 |
|
NotShadowStar posted:Wait what? I've been running Rails 3 on 1.9.1 since like December and have had nary a problem. I tried 1.9.2 the other week and things were horribly broken, WEBRick wouldn't even start on an empty Rails project. Ruby on Rails Blog posted:Note that Ruby 1.8.7 p248 and p249 has marshaling bugs that crash both Rails 2.3.x and Rails 3.0.0. Ruby 1.9.1 outright segfaults on Rails 3.0.0, so if you want to use Rails 3 with 1.9.x, jump on 1.9.2 trunk for smooth sailing.
|
# ? May 31, 2010 20:41 |
|
Beta 3 has been out for a month and a half. http://rubygems.org/gems/rails
|
# ? May 31, 2010 22:19 |
|
NotShadowStar posted:Beta 3 has been out for a month and a half. Obsurveyor fucked around with this message at 22:23 on May 31, 2010 |
# ? May 31, 2010 22:20 |
|
Evil Trout posted:I disagree. I've been running 1.9.1 in production for well over a year on a codebase that's 4 years old. The upgrade took maybe 3 days of work and resulted in a huge speed improvement (average of 2x as fast). I guess it depends a lot on where you work; I rarely have the free time to sink hours/days into a project for upgrading unless there's a need, and there's significant pressure to avoid needless hours billed to clients (or eaten internally). So in that kind of environment, one settles on a specific (old, readily available on most Unix distros) version and stick with it for quite a while Re: 1.8.7 marshal segfaults: I just got bitten by those recently, albeit in Sass (and via Nanoc, not Rails). Thankfully RVM let me set up 1.8.7-HEAD easily which seems to have fixed the issue. Speaking of RVM, anybody using the latest-n-greatest rip (i.e. the prerelease v2)? Still not a big fan of RVM's clunkiness w/r/t gemsets.
|
# ? Jun 1, 2010 03:22 |
|
if you're not switching ruby executables as well, is there any reason why it would be preferable to use rvm over simply vendorizing all your gems?
|
# ? Jun 3, 2010 23:38 |
|
Mr. Wynand posted:if you're not switching ruby executables as well, is there any reason why it would be preferable to use rvm over simply vendorizing all your gems? You can use gemsets sorta like bundler so you know exactly all the gmes your app sees and their versions. That said, after a (very) rocky start, bundler has gotten stable enough for me. We haven't had any huge problems for some time, and it works great for making sure dev, production, and ci all have the same poo poo.
|
# ? Jun 4, 2010 18:41 |
|
Pardot posted:So who else is headed out to Baltimore? I'm based in Baltimore also. Hint I'm the only fat one with a bmore on rails shirt on
|
# ? Jun 9, 2010 23:21 |
|
Obsurveyor posted:Same segfaults unless I use 1.9.2. My post about beta2 was just when it started and when they said something. Note my "Rails 3 trunk" too, i.e. the latest version from git(as of Friday when I messed with it last at work) segfaults as well. did you remove beta 1? There are a ton of errors if you try to keep both installed.
|
# ? Jun 10, 2010 00:13 |
|
asveepay posted:did you remove beta 1? There are a ton of errors if you try to keep both installed. edit: Well, this does not give me a lot of faith it is going to work: Yahuda Katz posted:We're not currently supporting 1.9.1, but we should possibly stop Rails 3 itself from booting on 1.9.1. We've gotten a bunch of obscure 1.9.1 bugs and have a lot of trouble keeping CI running on 1.9.1, but this is not the case about 1.9.2. Obsurveyor fucked around with this message at 16:32 on Jun 10, 2010 |
# ? Jun 10, 2010 15:21 |
|
That's just a lovely situation. 1.9.2 is known buggy and not in a releasable state yet, but if 1.9.1 has bugs that makes Rails 3 not working then... The 1.9.1 => 1.9.2 leap shouldn't be nearly as painful as 1.8 => 1.9 though, so as soon as 1.9.2 hits stable things should look up quite a bit.
|
# ? Jun 10, 2010 20:16 |
|
Looks like they went ahead with Katz' idea(from rails3 head):code:
I still do not agree with them targeting an unstable and unreleased version of Ruby but I am not going to sweat it until I run into issues( rvm). The other thing is, I thought odd versions of Ruby are development version and even are stable? If so, it could be a long time until there is a "stable" release. Obsurveyor fucked around with this message at 21:10 on Jun 10, 2010 |
# ? Jun 10, 2010 21:05 |
|
jetviper21 posted:I'm based in Baltimore also. Hint I'm the only fat one with a bmore on rails shirt on I didn't see is until too late, but bohconf was cool, thanks.
|
# ? Jun 11, 2010 03:09 |
|
I have been tasked with updating/rewriting a check out system that we use. The system resembles a library check out system. Currently the system uses a 4 digit unique identifier for each piece of equipment. The system needs to be updated to be able to handle any kind of unique identifier, we are switching to a to a new numbering system/barcode system. The system will now need to be able to handle the use of USB based scanner, for checking in and out. The use of the system will break down like this: 1.) A person will pick out a piece of equipment. 2.) They will bring it to me(or others that have the authority to check out) and ask to be checked out. 3.) I will scan the piece of the equipment with the barcode on it with the USB scanner. 4.) I will enter in their unique id to associate them with the check out of the equipment. 5.) I will enter in how long they want the piece of equipment checked out for. 6.) I will enter my username and password and check out said person. 7.) The person doesn't return the item in time based on the timeline they stated when they checked it out. 8.) Email will get dispatched to the user stating that they have the piece of equipment checked out and it will need to be returned. 9.) User brings the equipment back. I scan the barcode on the equipment with the USB scanner, enter in my username and password. Check in the piece of the equipment. I will also need to update equipment from the old system to the new system. When I find a piece of equipment that doesn't have the new unique identifier associated with it(not all at one time). I was shown the code/guts of the current system breifly, and had it dropped in my lap. I guess it uses Ajax, PHP, MySQL. I was told that the old system is worth scrapping and starting over on a new system is best I guess the implementation of the current system used a 4 digit identifier hard coded all over the place. I haven't looked into it.... I'm wondering if RoR is what I should use to for this project? I have not ever done any web development before.... I have coded in C++ and Java in the past ,but all real time. Never any database programming. I see that Agile Web Development with Rails book is recommended and I will pick this up if RoR is what I'm looking for? Where would I look for the handling of the USB scanner, could this be implemented in RoR?
|
# ? Jun 12, 2010 20:19 |
|
USB barcode scanners are almost always just another keyboard input. They translate a barcode (which is just an encoding of letters into something the scanner can read) into keystrokes. So that would be a matter of focusing on the appropriate text box on the form and scanning the code. As for the rest, yes I can picture how it works in Rails quite easily... but if you haven't done web development before Rails can be quite confusing. It makes things a whole lot easier, organized, faster to build than, say, PHP but it also assumes you've already built stuff before. Web development is a weird integration of disparate technologies that has lots of failure points, some entirely beyond your control. If you have experience in a M-V-C or M-V-P style program then you'll pick it up faster, but if not then you're going to have a difficult time.
|
# ? Jun 12, 2010 20:34 |
|
|
# ? Apr 24, 2024 15:57 |
|
I've been on Java web development big time the past couple years, before that PHP and PL/SQL, but something about Rails keeps drawing me back ever since I went through a few chapters of a Rails book. More recently I was playing around with Codeigniter for a side project and suddenly I had a yearning to get Railed. I have an old copy of Agile Development with Rails 2nd Edition. It seems to cover Rails 1.9. Would starting with this book put me in a bad place given that Rails 2 is mature and Rails 3 is imminent? Should I look around online for some Rails 2 tutorials? I primarily work in Struts2 on Java right now so a lot of the strong MVC concepts here ring my bell and I'm comfortable with them already. Its mainly the syntax and... looseness.. that is throwing me. 8ender fucked around with this message at 21:20 on Jun 14, 2010 |
# ? Jun 14, 2010 21:18 |