|
RonaldMcDonald posted:In my opinion you can see a lot about languages from how they solve simple problems. So, for how would the following PHP code look in RoR? You could do it like this but you're not supposed to: code:
|
# ¿ Aug 9, 2007 03:16 |
|
|
# ¿ Apr 29, 2024 05:13 |
|
I have a pretty serious question regarding rails log files in production. Every time a page is visited in your rails application there is a minimum of about 6 lines of information written about it to the log. Some plugins such as better_nested_set which is pretty drat well near necessary for some applications, there is a command that is going to be depreciated in an upcoming version of rails so you get about 30 or 40 (or however many rows of information are in your database) lines of text written to your log file, each one with a long description telling you about it. On a traffic heavy web site this log file will eventually get really big right? Isn't that bad? Regardless I want to turn it off. Thanks. vvvv Related to this is there a good place to figure out what environment.rb is not used for? Nolgthorn fucked around with this message at 20:28 on Aug 10, 2007 |
# ¿ Aug 10, 2007 20:04 |
|
scr0llwheel posted:So I'm thinking of starting a project with RoR but have one question: Is there a suitable way to do user registration, authentication, etc? Granted, I haven't looked into it very much, but all authentication stuff seems to be either the entire site or nothing. What I'd specifically like to do is to protect an admin control panel along with admin-only elements/controls on an otherwise publicly viewable page. If all you need is one admin user then you don't need restful_authentication, this is much simpler and should fulfill your need: Controller: code:
code:
Nolgthorn fucked around with this message at 03:13 on Aug 29, 2007 |
# ¿ Aug 29, 2007 03:10 |
|
smackfu posted:Rails makes me cry when I look at the SQL calls. I mean, it's very easy to get a working application, but then you wonder why it's slow, and it's because it's doing 100 db calls for a 100 item list. Oy. You're right it's not perfect but you also have to use it properly. @authors = Authors.find(:all, :include => ["books", {"screenplays" => "movie"}]) If the application is making 100 db calls for a 100 item list then you have forgotten to use eager loading. Now you can loop through, request the author.books or whatever and it won't have to get that information from the database for each one. Edit: Sorry, not intended to sound mean. Nolgthorn fucked around with this message at 07:15 on Aug 30, 2007 |
# ¿ Aug 29, 2007 03:36 |
|
It seems Active Record will not save grandchildren and their parent at the same time, am I doing something wrong or is it something to do with my polymorphic association?code:
It's not really relevant but here is a pastie of my models if someone needs to see. http://pastie.caboo.se/116397
|
# ¿ Nov 11, 2007 00:54 |
|
In this example SideColumn would not have been created yet so it would undoubtedly throw an error since ColumnImage would not have a row in the database to reference. I would have to save ColumnImage separately afterwards, but I'm trying to get it all into one nice neat transaction.
|
# ¿ Nov 11, 2007 01:14 |
|
I would understand that sometimes you might have to, but if you don't need to would you really try to host a Rails application on a Windows server?
|
# ¿ Nov 12, 2007 22:32 |
|
Try port routing in your router settings, set up port 80 to point to port 3002 on your local computer. This will only work if your ISP doesn't block incoming connections to port 80.
|
# ¿ Nov 14, 2007 09:03 |
|
skidooer posted:Your nil? check is redundant considering that blank? will return false if @posts is nil. Is "blank?" what I am looking for? I've always wanted something similar to @posts.title.empty_or_nil? In case the value being returned in the database is blank instead of nil for whatever reason, as nil.empty? would return an error. Or.. does it? I'm getting confused. I seem to just remember creating my own empty_or_nil? method at some point before to handle it. Nolgthorn fucked around with this message at 06:50 on Nov 20, 2007 |
# ¿ Nov 20, 2007 06:46 |
|
code:
This won't work properly otherwise without a little bit of extra declarations in your model and such specifying the ruby-way ness. You may have to fix the pluralization, to make tables the ruby way have them all named in the pluralized sense. Then to get information from it, pluralization starts to depends on what kind of relationship the tables have with one another. This should approximately begin to start to get at what you are going for. I think it might be a needlessly complex task, I don't know what the function of your application is so I can't tell. code:
Good luck!
|
# ¿ Nov 20, 2007 23:19 |
|
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 |
|
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 |
|
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 |
|
Hop Pocket posted:Thanks for the help with the RJS. I used the delay / duration combo successfully. Will look more into the method chaining, but that's just a bit over my head at the moment. For some reason I went a whole year before noticing the very helpful empty application.js file in the javascripts directory. It's just sitting there ready to be used for things like this, I went ahead and kept creating extra js files or used inline javascript instead of capitalizing on the convenience of it. So just a tip but if you haven't noticed it already, its there.
|
# ¿ Dec 18, 2007 00:22 |
|
MrSaturn posted:I use a plugin that uses the old style pagination, which has apparently been deprecated now with 2.0's release: http://api.rubyonrails.com/classes/ActionController/Pagination.html Pagination should look the same as it did before with classic_pagination, like this. code:
code:
http://nasir.wordpress.com/2007/10/31/pagination-in-ruby-on-rails-using-will_paginate-plugin/
|
# ¿ Dec 22, 2007 04:05 |
|
bmoyles posted:Someone pissed in Zed Shaw's cheerios "There’s no work for a smart man in a town full of stupid." This was my favorite part, I find it very funny. As well I got some good tips on new frameworks out of reading that, one or two frameworks that I want to use. Thank you. Edit: A lot of drama was in that read GEEEZ. Nolgthorn fucked around with this message at 11:23 on Jan 4, 2008 |
# ¿ Jan 4, 2008 11:19 |
|
Help! I have a technical interview coming up for employment in a salary based role using Ruby on Rails. Up until now all of my professional work with Rails has been under contract and I've done or learned about only what I wanted to know. I'm really nervous because I realize that -first of all- I want the job, but that I don't know dilly about what is expected when working with other programmers. That's not true, I learned some about Microsoft SVN while I was getting my MCAD in school, but MCADs don't help in Rails! Should I know about SVN, Mongrel, page caching and stuff because I don't know about those things. I've always deployed by hand to whatever was available on the server, I've created about 20 commercial web sites in the last year. Is there anything else I should quickly learn about in the next day or so that wouldn't have been covered in all the blogs out there?
|
# ¿ Feb 4, 2008 22:41 |
|
SeventySeven posted:I know Hobo is mentioned in the first few posts but has anyone done anything with it since? I thought I'd have a go at rewriting an existing Rails app with it to add some functionality (users and permissions) and to fix some problems with the old app. The problem I'm facing now is there's, as far as I can see, no documentation whatsoever for recent iterations of DRYML. Does anyone know if there is any reference at all? I am eagerly anticipating using datamapper in the future when it becomes compatible with Windows, so I hope that it is still under heavy development. My first impressions of merb about a month ago was that it was being heavily documented. Are these two things not the case anymore? Edit: Also I'm still waiting to hear back from the job I want, from earlier up on this page. I'll let you guys know how it goes, here's crossing my fingers!
|
# ¿ Feb 15, 2008 18:08 |
|
Nolgthorn posted:Edit: Also I'm still waiting to hear back from the job I want, from earlier up on this page. I'll let you guys know how it goes, here's crossing my fingers! I got the job, one question came up in the final interview of interest. If technology was today's, but my career was five years from now, then what do I see myself doing? Sort of a slightly different take on the "Five years from now?" question, supposedly to eliminate some of the "I'd be using space programming!" answers, which was my first instinct. Woo hoo!
|
# ¿ Feb 22, 2008 23:54 |
|
I have a $5/month account at https://www.railsplayground.com and host 4 small applications on it. What is all this dedicated talk, shared hosting is sufficient for a blog, band website, small business website and extraneous test or staging application. geez
|
# ¿ Jul 7, 2008 09:17 |
|
Lets say I have about 20 tables that include more or less each a set of options for 20 different select boxes. These will change rarely, I have set up all the functionality required to display these select boxes and show the user's selected options somewhere all over a page someplace. What is the best way to ensure there aren't 20 hits to the database on every edit request and a further 20 hits to the database on every page view where these results are displayed? I can use page caching where the results are displayed but I am a bit dumbfounded by the idea of caching the select boxes that allow the users to change these settings as they need to be pre-populated with the values the user has selected. Is the best way to just page cache on the edit page as well? Because the chances are that any time a user visits the edit page, they will be changing something that will clear the cache anyways. Nolgthorn fucked around with this message at 09:39 on Jul 18, 2008 |
# ¿ Jul 18, 2008 09:35 |
|
I am about to try and create my first plugin out of a CMS I built from scratch (with the help only of awesome awesome attachment_fu) but I've never created a plugin before and am having troubles finding a full walkthrough of the process and possibilities. The plugin will involve view helpers, controller methods and models. The CMS runs on a behind the scenes Admin interface with a different layout and a password. The front end needs to be highly configurable and the controller methods not so much so, this will be more or less an internal plugin that we are capable of making modifications to if need be. My question is where do I go to learn about the best ways of doing this that is not out of date?
|
# ¿ Jul 22, 2008 04:00 |
|
Making plugins is hard, would something this complex be better as a generator? Would that be any easier or more useful than having it as a plugin?
|
# ¿ Jul 22, 2008 08:03 |
|
Pardot posted:Having plugins that have views and stuff is hard in rails. There is something called plugin engines that do that, but it got some hate in 2006 from dhh, and I'm not sure what the current state of the project is. I went to the website and it's nothing but the poor developers overly defending the project like crazy for pages and pages and pages, geez. I'm so taken back now I'm not even sure what to do to start using the drat thing. All of the tutorials that are being linked to seem to be down, it looks like a nice project, being able to put a generator into a plugin sounds just the ticket. I'll try and investigate further. I wish that the developers of Rails engines spent more time writing documentation than they did actually listening to all this criticism, sometimes the Rails community baffles me. Nolgthorn fucked around with this message at 02:41 on Jul 23, 2008 |
# ¿ Jul 23, 2008 02:38 |
|
j4on posted:Let's say you work in a "fast and dirty" coding environment (news website) where most projects go from design to publish in under a week, sometimes only one day, and usually involve only one coder. Maintenance on old code is rarely needed, but deadlines absolutely can not be missed: if breaking the MVC paradigm will save one hour, by God break it. For these kind of small data-driven "mini-sites" is RoR still better than PHP? Or should I be lookng to learn something else entirely? I would recommend spending any downtime you have building something which can be reused to build what you most usually do instantly. That or switching to Django, if you can manage Django it was actually built for news websites by a large news website something or other and does everything you want fast. Once you've defined what your database looks like all you need to do is build a front end, the administration portion is already done, fyi but I find it hard.
|
# ¿ Jul 23, 2008 21:54 |
|
Re; Rails Engines AGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH *falls over* *twitches* Thanks Rails community for doing everything in your power to prevent Rails Engines, which is exactly what I need from having been updated in a year so that it no longer works. That's great how something that obviously had a lot of time and effort put into it got flogged so badly that the developers finally said 'gently caress this' and gave up on it. Rails is now much better for not having this plugin available to those who would have wanted it in the future. I'll surely not be considering contributing a lot of my time and effort into a community if there is a risk my work will be responded to as if it were a youtube video.
|
# ¿ Jul 23, 2008 22:42 |
|
I've tried all the versions... maybe I'm doing something wrong.
|
# ¿ Jul 26, 2008 10:55 |
|
luminalflux posted:Yes, I should probably just let my database be a stupid object store, but a lot of habits (foreign keys, naming primary keys to make joins easier) are hard to shake. Really I found that easy, as soon as I didn't have to touch the database anymore I simply didn't. The added benefit of never having to bother doing anything other than change the data store any time I wish was a great benefit as well. Edit: Also the ease of using sqlite3, which is my favorite data store.
|
# ¿ Aug 6, 2008 23:12 |
|
http://weblog.rubyonrails.org/2008/8/23/dos-vulnerabilities-in-rexmlquote:The ruby-security team have published an advisory about a DoS bug affecting REXML users. Almost all rails applications will be affected by this vulnerability and you’re strongly advised to take the mitigating steps recommended in the advisory. If you’re not sure whether your application could be affected, you should upgrade. I also got a message from engineyard urging me to fix my installation. quote:Security researchers have uncovered a denial of service vulnerability in the standard Ruby REXML library[1] used to parse XML. Ruby on Rails will attempt to process incoming XML requests by default, regardless of whether your application utilizes XML explicitly. All customers utilizing Ruby on Rails are encouraged to apply the fix immediately. The patch is available from the official Ruby on Rails Weblog[2] along with instructions appropriate to the different versions of Rails. But as usual I cannot figure out what the big deal is, what happens if someone utilizes this security hole in one of my many Ror applications?
|
# ¿ Aug 28, 2008 04:24 |
|
Pardot posted:Also has anyone set up nginx to proxy to different apps, but not using subdomains? Like me.com/app1 me.com/app2? I can't quite get it to work. The only way to do this is to not have public_html be a symlink, as *nix does not support running two daisy-chained symlinks. Or at least that's what I remember the issue being, there is definitely an issue there whatever the issue is.
|
# ¿ Oct 11, 2008 15:01 |
|
I am trying to create a site that is kin to okcupid and need some location based plugin to sort out where cities are and their proximity to one another. All of the geography based plugins seem to place a lot of emphasis on street names and zip codes, following which it performs and off site lookup using google and whatnot. All I really want is some database tables filled with countries, provinces and cities with the latitude and longitude filled in, then a method which can do lookups based on location and search radius. Where can I find something more along the lines of and specific to what I need? For my purposes there is not any reason to be able to type in the city name, a drop down list is ok as that would be close enough. Help!
|
# ¿ Oct 21, 2008 03:10 |
|
What the heck I'll just GeoKit it, this seems to be the new way of doing things.
|
# ¿ Oct 21, 2008 04:27 |
|
I just felt like popping in on this thread really quick. Doo doop doouuu doo doo! Doo doo doo ooo doo!
|
# ¿ Oct 30, 2008 05:48 |
|
atastypie posted:You have to restart your server any time you change your routes file. That is false, you do have to restart your server anytime you change your environment.rb, database.yml, or vendor directory. Routes can be altered on the f.l.y.
|
# ¿ Nov 24, 2008 10:11 |
|
phazer posted:Can someone point me in the right direction for doing multiple file uploads in Rails2? I want to have 1 upload field with the ability to add more through AJAX. I'm googling but finding nothing valuable. Here is a resource that does something like you want. It's not bad but I'd be wary; look at the updated code snippets on the page and read the comments because the video might be old. http://railscasts.com/episodes/75-complex-forms-part-3 Flobbster posted:Speaking of deployment... With regard to SVN and github and Capistrano and all that crap, you don't really need to use Capistrano to deploy your application. Find a good host that supports Rails and check out their FAQ section, most of them will walk you though getting your application running through FTP (or SFTP if you prefer) and a terminal window. My favorite program on os x for doing this is Coda, I don't know if I'd use it for development but it makes it easy to work on files that are server side. It's pricey but there is a demo available that will get you running. On Windows I recommend WinSCP, WinSCP rocks. Honestly if you try and jump right into Capistrano with your pants off you're going to get decapitated, I know a lot about how Capistrano works and have had to use it a huge number of times after getting 1 on 1 training. I think it is absurd, overly complicated, useless for something as simple as most Rails apps are. Here is my favorite host's deployment FAQ. http://wiki.railsplayground.com/railsplayground/show/Troubleshoot+Common+Rails+Deployment+and+Setup+issues
|
# ¿ Dec 17, 2008 00:40 |
|
Flobbster posted:Thanks for this. I've been reading a little more ("Deploying Rails Applications" from Pragmatic Bookshelf) and if I'm understanding everything it looks like Capistrano does everything over SSH, which means it's out for me -- the host I'm using charges extra for SSH each month, an option that I declined (the site I'm designing is just a simple art site for my dad, so there's no reason for him to pay for something he'll never use, and once the site is deployed I won't need to touch it very often either), so that's why I've been so concerned with a simple "upload and go" method of deployment. I don't think it is possible to restart the mongrel service your app is running on without SSH and I don't think it is possible to run rake tasks without it. If you run the rake tasks locally, then export and insert the database changes onto the host's phpmyadmin you might be alright. You'd need to contact their support every time that you need to restart the mongrel service. If I were you I'd pay for SSH or get a better host, charging you to use SSH is a sort of manufactured fake service fee. A few quick tips for deployment without capistrano. 1) Freeze the plugins, gems and rails to your vendor folder before uploading. 2) To reduce the chance of corrupted files, either gzip your project before uploading it and ungzip on the server or use SFTP/SSH protocol to transfer it. 3) Upload your application somewhere on the server outside of ~/public_html. 4) Set the permissions recursively on the entire application that you uploaded to 755. 5) Some hosts don't like this on writable directories, so you may have to change your log directory and any file storage directories to 777. 6) Manually update the ~/app/public/.htaccess file to reflect the server and the fact you want to use dispatch .fcgi not .cgi as the file being referenced. 7) Check to ensure ~/app/public/dispatch.fcgi has the correct #!bash line. 8) Create the database on the server, update the production config.yml to use the new db settings. 9) Populate the database with rake. 10) Manually update environment.rb to remove the comment before the environment = production thingy. 11) Delete ~/public_html then create a symlink to the ~/app/public directory in its place. 12) Restart mongrel. If you are developing on a Windows machine then there are a lot more steps that would need to be added to the above list, all other operating systems (*nix/osx) you will be fine. Alternatively you can go through the motions to use capistrano, but you'll find the above steps to be much faster. No matter what OS you are using capistrano just takes all the stuff you would have to do, adds a lot more convolution to it, then forces you to start over again when you don't configure it not to break itself every time. Someone probably has had a different experience with Capistrano that I have, but regardless it is bloated and absurd. I was thinking all we really need is a simple bash script that does all this stuff anyone up for it?
|
# ¿ Dec 17, 2008 04:44 |
|
I would pay $5 a month and do, it is not a huge sum of money and you get what you pay for. If they provide you with a utility to restart mongrel services with the click of a mouse it is still a hack but at least they give you something.
|
# ¿ Dec 17, 2008 15:18 |
|
I have an Entries model and I have a Votes model. Each Entry has many Votes and each time that an Entry is loaded, the associated Votes will also need to be loaded, is there a way I can use scope to automatically :include => :votes on each request? Or is this not good practice?
|
# ¿ Dec 21, 2008 15:13 |
|
Thanks for the advice, I am using named_scope now. I have some restful routes in my application, shorthand it looks like this. code:
Before I started using rest Rails was good at picking the shortest url because I would always put the shorter urls lowest in the order. Or do I have to start explicitly using root_path instead? Nolgthorn fucked around with this message at 04:53 on Dec 23, 2008 |
# ¿ Dec 23, 2008 04:46 |
|
|
# ¿ Apr 29, 2024 05:13 |
|
That didn't really seem to fix it, my routes are a bit more verbose, let me post in more detail including your suggestion I'm still getting directed to /entries with entries_path.code:
|
# ¿ Dec 23, 2008 05:17 |