|
phazer posted:When I use before_filter :login_required I get an undefined method error. 1) I have a feeling that in your action you are trying to muck with a "login" variable that is undefined- if there is no local variable defined, it will look for it in the next best place- a method on your BandsController instance (where it can't find it because it doesn't exist, so it tosses). The important thing to remember here is that Rails controllers aren't magic. Your "actions" are just methods in a class. Each action is an instance method, and "self" inside of actions is the instance of your controller class. (If that doesn't make sense, Google "Object-Oriented Programming") Try to think of what you're doing inside of a Rails action as a normal method call, in a normal class only your return is a little weird (You are quite literally returning your render/redirect method call). 2) The media temple stuff has nothing to do with this. You should be doing all of this stuff locally anyways. Only once you get a working application should you be deploying to a webhost. For some reason I'm assuming you're on windows- don't they have one-click Rails installs and whatnot? Use those.
|
# ¿ Dec 9, 2008 22:37 |
|
|
# ¿ Apr 25, 2024 22:17 |
|
phazer posted:I did have a working application before I deployed. In fact, it was working AFTER deployment until this restart issue. It is Media Temple. They said my Mongrel gem is corrupt and they don't know why. And I'm on OS X. Well, to be sure, the mongrel pid problem and the nomethoderror problem are two different problems. If it is working locally but not working remotely on the same code, all I can say is make sure you've run your migrations. The chances of your mongrel gem being corrupt are slim to none. The mediatemple people have no idea what they're talking about. How did you do the restart? Is this a full-on VPS or are you stuck on some shared thing?
|
# ¿ Dec 10, 2008 22:42 |
|
phazer posted:I got: Just do code:
|
# ¿ Dec 12, 2008 00:48 |
|
phazer posted:Same exact error. Like I said, MT support is on it... just waiting to hear back. Ugh. I'd ditch MT if I were you. I had a deal for free MT hosting for a year and after 6 months decided to pay for hosting rather than keep using them. They're really quite awful. Get a $20 account at Slicehost. Sure it might be a bit more, but you'll be saving yourself so much time by not having to deal with the crap that MT forces you through.
|
# ¿ Dec 12, 2008 17:59 |
|
atastypie posted:Do you mean MT in general, or MT specifically for Rails? MT for Rails. If you use PHP, I'd imagine it would be just fine.
|
# ¿ Dec 12, 2008 20:03 |
|
phazer posted:I will say deploying an existing rails app on Media Temple was WAY easier than dreamhost. (before i decided to restart the application) Hah, yeah, dreamhost is a whole other can of worms. I'm hoping that these hosts get their act together soon and start using Passenger. There's no reason not to at this point- it is so much better for pretty much any setup. Using a whole VPS for a toy app is overkill.
|
# ¿ Dec 12, 2008 23:05 |
|
Flobbster posted:Speaking of deployment... You can set Cap to deploy_via :copy, which is what I recommend for the time being. I think there are a couple of plugins to capistrano which will allow you to do rsync, which would be better. Obviously using source control and deploying from there is the way to go, but this should get you over the hump.
|
# ¿ Dec 12, 2008 23:12 |
|
dustgun posted:Route generation question time: Use to_param code:
|
# ¿ Dec 15, 2008 18:36 |
|
dustgun posted:Oops, I should have mentioned I knew about to_param. Any particular reason you want it to be person/schmoe/joe? Purely aesthetics? Going down this path seems like bad news to me.
|
# ¿ Dec 15, 2008 20:13 |
|
dustgun posted:It was a somewhat contrived example that I didn't fully think through. Why not just escape/sub the / before the mask? The only thing happening here (I think) is that the slash in a CIDR just happens to be the same character as a URI delimiter. I see no problem with "/cidr/1.88.238.0|24" or something similar. Just gsub in the controller to get it to 'proper' format. (I know this isn't what you're really looking for, but I'm a sucker for shortcuts.)
|
# ¿ Dec 15, 2008 22:13 |
|
phazer posted:I'm using attachment_fu and rmagick to create an application for uploading PSDs and I'm unable to find, via google, a solution that converts the file into JPGs for making lightbox previews of the PSD. (I still want the PSD stored on the server, too, though.) There's a tool that comes bundled with ImageMagick called 'convert'. Call from the command line "convert x.pdf x.jpg" and you're golden.
|
# ¿ Dec 16, 2008 20:03 |
|
jonnii posted:He said psd, not pdf. If I remember correctly, ImageMagick can convert PSD files, but I'm not sure how up to date their support is. Worth a shot though. Oh poo poo you're right. convert should still work with PSDs, but it seems kind of sketch.
|
# ¿ Dec 16, 2008 23:32 |
|
Flobbster posted:I'm keeping the 'show' action separate and protected behind the authentication :before_filter because it's intended to be used in the admin section of the site (along with the other actions) to show additional private information, with a different layout. 'display' is essentially a simplified version with a different layout, intended for public viewing. Dude, that's what if statements are for. Seriously. code:
|
# ¿ Dec 20, 2008 00:32 |
|
Flobbster posted:I'll rename it "enlarge", so we stop getting hung up on the synonym and overlooking the actually problem here, which is why an action method isn't getting called. You know what, that would fix it. "display" is a preexisting method in ActionController. Edit: Oh, there was a new page I didn't see and you found that out already. Awesome.
|
# ¿ Dec 20, 2008 06:17 |
|
phazer posted:How do I put links in a boolean output? Can I? There must be a way. I prefer to do code:
|
# ¿ Dec 21, 2008 02:02 |
|
phazer posted:No clue. Look at the Javascript that Rails is pumping out, and see what's wrong with that. I hate RJS for just this reason.
|
# ¿ Dec 23, 2008 20:32 |
|
So... Merb and Rails are to merge for Rails 3. Thoughts, everyone? Personally, I'm kind of pissed off. There's a reason I stopped developing in Rails and moved over to Merb. The way Rails handles rendering is enough to make me hate the thought of going back.
|
# ¿ Dec 23, 2008 21:24 |
|
Pardot posted:Yeah we'll see how it goes. If it ends up being the best of the two, that'll be great. I'm all in favor of choice, but since I already had that with Merb, I don't really gain anything. I'm not sure why this is good for Merb, either. I, personally, didn't see the competition between the two frameworks as a bad thing. dustgun posted:I was just about to start playing with merb today but now it feels horribly moot It might actually benefit to start learning Merb. It'll get you prepared for Rails 3, which, after reading more, might be very heavily impacted by the Merb merge. Overall, this seems like it is great for Rails people and "Meh?" for Merb people. I haven't seen a Merb person (aside from the Core team) who is particularly excited about this.
|
# ¿ Dec 23, 2008 22:03 |
|
Nolgthorn posted:
Oh. Gosh. Where do I start? First thing's first: Controllers should be skinny. Something is wrong if your controller has any logic that is concerning anything other than these things: Rendering, redirecting, security, requests, sessions or parameters. "Business logic" has absolutely no place in the controller. Get that stuff to the model, and I think you'll find a lot of the complexity will melt away by itself. Secondly, this stuff is so much easier to test once it is in the model. You should have comprehensive unit tests built around this stuff. That way, you KNOW it works, instead of the "test and refresh" method of "testing" your code (Where you THINK that it PROBABLY works). If it doesn't work, you know exactly what is wrong. Thirdly, fetching your @forum_thread should probably not be in a before_filter, but if it is, verify_is_owner should be called along with it. That way, by the time you get in the method body of "update" you know everything is kosher with permissions and you can just keep going. Fourthly, you should definitely be using a different attribute name than updated_on. You're not really tracking updated_on in this case, so rename the dang thing. Fifthly, use && instead of "and". They are NOT the same thing. They have different precedence. code:
I don't mean to harsh on you, but it's best that you learn these conventions as quickly as possible. It's better for you, and for anyone who might have to read your code in the future. (Also, in response to Hammertime, I never use save!. I'm not sure if it is just preference or what, but I like if->else over begin->rescue)
|
# ¿ Dec 29, 2008 17:01 |
|
Pardot posted:What do you guys like better: braid or git submodules? Both have been frustrating. I gave up on submodules. I just commit everything straight into the repo. You suffer from a dirtier history, but it is so much easier to deal with and deploy. I might try it again though. The primary reason why i gave up on it was because I was still using git-svn (for Trac), and submodules don't work at all with git-svn. I've never used Braid... How is it different from Piston?
|
# ¿ Jan 12, 2009 17:27 |
|
mister_gosh posted:I'm considering learning and writing a RoR program(s) basically for the hell of it, to learn it. I have a need for a web application that is database dependent (Oracle 10g). If I do not go with RoR there is no way I'd even consider PHP, I'd use Java, JSP, Javascript, etc. Learning a new language is never a poor use of your time. This is, also, exactly how I got started with Rails. The Oracle adapter is stable and works well. Running Rails scripts from the command line (really, you're likely to just be using ActiveRecord from the command line) is easy. The best way to do it is with Rake tasks. There should be a guide or something out there if you want to Google it. If you just want to interact with the Oracle database with command-line scripts and have no interest in the Web part of it, you might want to start out with just Ruby and the ActiveRecord gem. Create some simple scripts, and just "require 'activerecord'" and start going. There's no need to have the big directory structure and all of that if you don't need it.
|
# ¿ Jan 30, 2009 17:08 |
|
Sewer Adventure posted:The thing about that strict MVC enforcement poo poo is sweepers don't work when I'm using cron jobs to call script/runner to invoke a Model.method You might want to look into Observers. That way you can keep strict MVC separation but also have it work with models alone. I've used Observers for permissioning for the same reason, and it worked really well.
|
# ¿ Feb 2, 2009 17:25 |
|
mister_gosh posted:I'm watching a Rails screencast from peepcode (Rails from scratch part 2). I have tried to watch it a couple times now and 3 minutes in I always turn it off and try to read other resources to confirm something. You don't have to use the generator, it is just easier. In your case, just create a file in app/models called "book.rb" and start it thusly: code:
Edit: Also, testing will be difficult in this scenario and I honestly don't know how you'd be able to do it.
|
# ¿ Feb 4, 2009 18:26 |
|
Hop Pocket posted:Regarding restrictions -- a lot of it has to do with whether or not there will be different applications hitting the same database. In that case, it makes a lot of sense to back up your model validations with database constraints. That way at least you can be sure that your database will not be left in some crazy state by a non-Rails process that also happens to be writing to it. I'm currently working on a project that has a DB that both the Rails processes and a Java server process access, and it's pretty essential that the constraints be definitively defined at the DB layer. Now, why some would assume that to be the default when creating migrations, I suppose it's really just a matter of preference to the coder. I believe the reason that this is done is with error handling. Databases give lovely and sometimes hard to determine error messages for constraints. Not saying it couldn't be done, but a lot of work would have to be done for each adapter to make it viable. I think this is something that will eventually come to Rails, but not for another couple of years still.
|
# ¿ Feb 17, 2009 04:47 |
|
Nolgthorn posted:I've always felt after being tutored on and using capistrano that it is far too complex for something as simple as a rails deployment. I can perform deployments faster with less issues just using a SFTP client of my choosing. Try out Vlad. http://rubyhitsquad.com/Vlad_the_Deployer.html
|
# ¿ Feb 20, 2009 18:18 |
|
savetheclocktower posted:To each his own, of course — HAML has many zealous users and I'm sure it is well-made — but the trend of applying a Ruby frontend to everything drives me insane. Eh? Haml isn't any more Ruby than ERB is. Haml is a re-implementation of HTML using a more terse syntax. There are Haml libraries for Python, and several other languages I believe.
|
# ¿ Feb 21, 2009 07:20 |
|
manero posted:Oh great, no more capistrano? I think someone will most definitely pick it up. There are too many people using it (not even just in the Rails community) for it to die, really. I think Jamis handled this poorly. He should have asked for help a lot earlier, and he could have switched to a "project manager" kind of role a long time ago, kind of like DHH with Rails. For whatever reason, Capistrano was always viewed as "his" project, and bug reports, patches, etc always went through him. That's why he got burnt out, and I think that burn out was completely avoidable. That said, maybe Capistrano should die. It is pretty much a reimplementation of Rake, only less awesome. Maybe this will get people to consider alternatives like Vlad more seriously. There's no reason for a deployment solution to not use Rake. Jamis is a great developer, but his projects are always way too grandiose.
|
# ¿ Feb 26, 2009 18:37 |
|
Nolgthorn posted:What I want to do is eagerly load the information in this table depending on both which user is logged in and which conversations are currently being viewed. Right now my models simplified look like this: If I'm understanding you correctly, I think this will work: (Example for Conversations#Show action) code:
If what you want is this stuff to be automatically loaded in the model, I think you're looking in the wrong place.
|
# ¿ Mar 12, 2009 15:41 |
|
Nolgthorn posted:Something tells me I'm not doing this the rails way and I'd like to, unless this is the rails way and I'm just confusing myself. Well, the "Rails Way" is has_and_belongs_to_many, but you can't use that because (if I read correctly) you have extra attributes you need to keep track of. I really can't tell what you're trying to do, but you're doing it wrong. You're overthinking it. This is really quite a simple thing. code:
|
# ¿ Mar 12, 2009 23:11 |
|
skidooer posted:The "Rails Way" would be to use has_many :through, which is essentially what he is doing, save actually defining the through association. If I'm understanding his models correctly, you couldn't really use has_many :through in this situation. I think what is going on is that a user can "own" a conversation (they started it, presumably), and that each conversation has an owner (what user started it). If this is not the case, then things change drastically. However, I have been working off of this assumption Nolgthorn posted:that is what im doing. I think in order to eagerly load your ConversationUser, you'd have to do this in your controller: If you want to know about only the currently logged in user: code:
code:
|
# ¿ Mar 13, 2009 20:12 |
|
Nolgthorn posted:This works like an absolute dream, I could not be happier, it's about 100% workload off my mind and you'll have to trust me on that. OOP and VMMPY and OSYYTR all be damned, this is too elegant to not use. Sorry, I really tried to be nice about this but you seem intent on ignoring the simple solutions we keep telling you about. So I can't be nice anymore. You better hope that nobody else has to see that code or ever maintain it, because they're going to have an absolute shitfit. YOU'RE DOING IT WRONG. That solution violates MVC, is fragile as hell, and is way too complicated. This is the absolute farthest thing from "elegant". If I had you fix one thing though, it would be this. Do not ever do this. Ever. WRONG: code:
code:
|
# ¿ Mar 16, 2009 17:12 |
|
skidooer posted:That will query the conversation_users table for every conversation row, exactly what Nolgthorn is trying to avoid. Yeah you're right, but this was the least-bad option of him insisting to have logic in the model that doesn't belong there. In my first reply to him I suggested a load from the controller, which is still the best, easiest, fastest, and most correct way of doing it.
|
# ¿ Mar 16, 2009 22:40 |
|
Lamont Cranston posted:I'm trying to implement custom 404 pages using method_missing in my ApplicationController. This code: Why not just: code:
|
# ¿ Apr 12, 2009 19:20 |
|
theEZkill posted:Yeah I noticed that when I was researching rails this morning- this is for building apps, not running scripts. I just talked to him about it over dinner and he said it was for sure RoR and it's pretty much copy/pasting a script to automate Twitter. What exactly does it do? No idea. You can have a Ruby script that doesn't use Rails, and call it from the command line.
|
# ¿ Apr 25, 2009 17:31 |
|
KarmaticStylee posted:what's the best base install when u set up on slicehost? Debian
|
# ¿ May 3, 2009 02:53 |
|
NotShadowStar posted:I still don't know what the gently caress the core Ruby team was thinking. They improved the core aspects of the interpreter that were the primary weaknesses, the GC and execution speed, and it was amazing. Then they go and make fundamental changes to the language AT THE SAME TIME. ARGH. A point revision in Ruby is not like a point revision in any other software. Ruby 1.8.0 came out in 2002,, so it has been 7 years since fundamental changes have been made to the language. It is about drat time, whether or not the internals have been overhauled at the same time or not.
|
# ¿ May 14, 2009 19:14 |
|
Clock Explosion posted:I'm trying to set up Integrity using Thin on an Ubuntu Jaunty install for work purposes. I'm getting an error when trying to start the Integrity server that says If you can, uninstall the lower versions of those gems, and one of two things will happen: 1) everything will work, or 2) It will give you a more specific error about who is trying to require that version of rack. This has happened to me before with Merb when I was careless about messing with system gems and vendored gems. The Passenger process, in my case, was using the system gem, and my app was trying to load up a different version out of the bundled gems. Kind of vague, but I hope that helps. These problems are insanely hard to debug.
|
# ¿ May 26, 2009 16:48 |
|
Plastic Jesus posted:Is it possible to load the code for a lambda from a file? Not exactly what you're talking about, but sweet Jesus my life would be a whole lot easier if you could store blocks in a database. Lisps can do it, why not Ruby?
|
# ¿ Jun 9, 2009 20:46 |
|
Upgraded a Merb app that uses a custom Couchdb adapter to 1.9.1 and it was fairly easy. Only two or three fixes were necessary. It gave me a chance to clean up my gem situation, so now almost everything is vendored- my only system gems are rake, fastthread and passenger. Overall I'm pretty happy with it- ordered hashes are great, and I think I'm going to like the new hash syntax. I haven't delved into many of the other changes. Speed-wise I really can't see a difference. My test suite runs in the exact same amount of time- ~0.8 seconds for unit and ~5.4 seconds for functional. I thought it would cut it down by like 20% but the difference is negligible if it is even faster at all. I suppose most of the time in tests is IO (database, etc), so I don't think there would be much difference regardless of the language.
|
# ¿ Aug 4, 2009 17:25 |
|
|
# ¿ Apr 25, 2024 22:17 |
|
dustgun posted:I've spent all day trying to get prawnto & prawn to render layouts. I want to shoot myself in the face and I think I'm just going to hack something up so that ... something something and then it works. What's wrong with pdf-writer? Magicmat posted:I know ruby 1.8 but never so much as glanced at 1.9 until I saw how god damned fast it was and that rails now supports it. I know 1.9 has some major, incompatible changes with 1.8, so what's the best way to learn it? Is there a webpage out there with a list of changes, and is that enough to learn 1.9? Or should I get the new 1.9 pickaxe to compliment my 1.8 pickaxe? What about O'Reilly's 'The Ruby Programming Language'? A lot of people are saying it's better than the pickaxe, and it says it covers both 1.8 and 1.9, but it was published 18 months ago, is the 1.9 info still accurate? There aren't really that many differences. Just update your ruby binary and run your old projects and see what breaks. My main project (~5000 LOC) only had 2 or 3 places that required minor changes. Took maybe 30 minutes to upgrade. The biggest gotcha had something to do with require and load paths, but I can't remember the specific problem at the moment.
|
# ¿ Aug 26, 2009 15:54 |