|
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 |
|
|
# ? Jun 5, 2024 03:12 |
|
mister_gosh posted:Can it communicate with COM objects?
|
# ? Jan 30, 2009 18:34 |
|
If it's mission critical for you to be able to access COM objects you might not want to go with rails. That said, you can probably access COM objects through java if you use jRuby. Jruby allows you to mix and match java and ruby code in your rails application. The COM stuff could be written through java over some sort of COM bridge. There are some downsides to JRuby though, like the fact that you cannot use any gems that have anything that compiles natively in C. You have to rewrite those gem's functionality in java or use a java backed gem that has been created. Anyway COM with rails sounds like more trouble than it's worth.
|
# ? Jan 30, 2009 19:06 |
|
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. Learn RoR without the idea of COM, just learn Rails as Rails first. I've been running into a lot of things that Rails doesn't do automatically and it's difficult navigating around the core trying to figure out where I should modify things. Once you have a grasp on how a Rails application works, then you should think about where you should hook into external objects using non-Rails ways. (I'm guessing you're using COM as a broker for proprietary data, in which case you'd create a non-ActiveRecord model using Win32API and create methods in the model to interact and get data)
|
# ? Jan 30, 2009 19:49 |
|
Has anyone tried RubyMine, from the makers of IDEA for Java? That was (and probably still is) an incredible development environment, I'm still new to Ruby and Ruby tools but I'd be interested to hear experienced coders' opinions as I imagine coming from IDEA it would be easy for me to learn RubyMine.
|
# ? Jan 31, 2009 04:55 |
|
How can I expire a cache from a model? expire_fragment only works in controllers.
|
# ? Feb 1, 2009 02:57 |
|
Sewer Adventure posted:How can I expire a cache from a model? expire_fragment only works in controllers. The best idea is to use sweepers and set them up to expire the cache when the model performs certain actions. At least that's what everyone will tell you in order not to break MVC. Alternatively you can just explicitly call the method you need using something like this: code:
|
# ? Feb 1, 2009 21:27 |
|
Nolgthorn posted:The best idea is to use sweepers and set them up to expire the cache when the model performs certain actions. 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
|
# ? Feb 1, 2009 23:15 |
|
Rails 2.3 is out. http://guides.rubyonrails.org/2_3_release_notes.html - surprisingly great post about all the new stuff. Anyone going to be at acts as conference this weekend?
|
# ? Feb 2, 2009 03:42 |
|
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 |
|
Pardot posted:Rails 2.3 is out. http://guides.rubyonrails.org/2_3_release_notes.html - surprisingly great post about all the new stuff. A small correction: it's a release candidate, not an official release yet. http://weblog.rubyonrails.org/2009/2/1/rails-2-3-0-rc1-templates-engines-rack-metal-much-more
|
# ? Feb 2, 2009 21:43 |
|
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. He states that with: code:
He also states that this puts together a migration that will build these tables in your database. The application I hope to build while learning Rails is to work with an already existing, and partly 3rd party, database. This database does not have "s" at the end of each table name (am I breaking some cardinal RoR rule here?). I'm thinking I probably don't want to build a scaffold as the migration is not needed, but then I feel like I'm missing the point here. Does an entire RoR application have to include the creation of almost proprietary type tables for Rails to work with? They can't already exist? By not building a scaffold, am I missing a major point in the ease of building web apps using rails? I just started learning, so feel free to just say "keep reading" if my questions make no sense.
|
# ? Feb 4, 2009 18:14 |
|
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 |
|
Praetorian42 posted:You don't have to use the generator, it is just easier. Or you could just run scaffold, then delete the migration and then set up your tables as you suggest. As for testing, you can clone an existing database via the 'rake db:test:clone' command (although this might fail). See this blog post I found about testing non rails apps via rails which might be useful: http://www.martinicity.net/articles/2007/03/31/testing-a-non-rails-application-using-rails
|
# ? Feb 4, 2009 19:49 |
|
I've been playing around with Authlogic for my new application. It seems to me it is very nice. For some reason it doesn't have a great grasp of telling me what is best for my database while using it. For instance, the suggestion on the site offers migrations which include :null => false on just about every single field and things like :default => "" etc, but not in all examples. Why are things like this so prevalent in so many gems and plugin tutorials out there? Personally I prefer to handle all of that "is-it-blank?" validation stuff in the model, if it gets by the model I probably planned on it going into the database not being rejected for some reason after it gets there or being replaced with "" instead of being null. The other thing it seems to not be mentioning is to add indexes to any of the database fields, is this common practice too? I would think for logging in purposes things like the login field should be indexed. What about all of those <blank>_token fields? Those should be indexed too... I'm always so confused when I hit the migrations portion of any tutorial because they still seem to not do things the way I do them. Is there a benefit to not indexing fields and is there a benefit to adding restrictions or defaults to the fields in a clean database? Edit: Besides setting a boolean field to default false or a <blank>_count field to 0... Also doesn't setting a default on a field in migrations negate the :null => false assignment anyway? Nolgthorn fucked around with this message at 07:29 on Feb 16, 2009 |
# ? Feb 16, 2009 07:10 |
|
Nolgthorn posted:I'm always so confused when I hit the migrations portion of any tutorial because they still seem to not do things the way I do them. Is there a benefit to not indexing fields and is there a benefit to adding restrictions or defaults to the fields in a clean database? In general, I believe indexes are left out because it really depends on the usage pattern of the application. In a use case where you're only dealing with a small number of rows it probably does not make a huge difference. Separating them out further defines the boundaries of the relationships between the app developer and the DBA (who's job it is to make sure the db is running well). That having been said, I as a rule create indexes on obvious foreign keys. I have also never had the benefit of working with a DBA. 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.
|
# ? Feb 16, 2009 23:46 |
|
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 |
|
Hey, I was wondering if anybody could help me with a little problem. I'm trying to learn Ruby on Rails and while setting it up in Ubuntu (intrepid ibex) everything seemed to be going alright until I started a new project and tried to run the web server. It gives me this whenever I try to run it:code:
|
# ? Feb 19, 2009 00:38 |
|
edit: Dang, I have never seen that error before. In other news Passenger is awesome, but first load is slow. Sports at 11. Trabisnikof fucked around with this message at 01:02 on Feb 19, 2009 |
# ? Feb 19, 2009 00:57 |
|
Ah yes, the Ruby install in Ubuntu is kind of half-broken because of bad choices, and unfortunately the maintainer still hasn't fixed it. I remember you have to install the openssl devel libraries, then getting the Ruby core source, then recompiling OpenSSL from there http://www.slashdotdash.net/2007/06/27/problem-with-openssl-with-ruby-1-8-6-on-ubuntu-fesity-7-04/ However since you're at that point I'd just recompile Ruby 1.8.7 from source anyway and replace the unoptimized Ubuntu version, which is 1/2 has fast as a compile from scratch version. No idea why. (Install from source is really, really easy. Get source, extract, cd ruby-src, ./configure && make && sudo make install. Done) http://antoniocangiano.com/2008/12/09/the-great-ruby-shootout-december-2008/ NotShadowStar fucked around with this message at 01:04 on Feb 19, 2009 |
# ? Feb 19, 2009 00:58 |
|
Trabisnikof posted:In other news Passenger is awesome, but first load is slow. Sports at 11. Yeah, this pisses me off too. I modified my PoolIdleTime to something like 3000s instead of 300s to avoid having to let the sites spin up. Not sure if there are any major drawbacks to that, I'm not aware of any.
|
# ? Feb 19, 2009 01:17 |
|
NotShadowStar posted:Ah yes, the Ruby install in Ubuntu is kind of half-broken because of bad choices, and unfortunately the maintainer still hasn't fixed it. Used this to fix it, thank you very much! EDIT: Yay, a new problem. I need to "gem install sqlite3-ruby", but it gives me this: code:
El Generico fucked around with this message at 02:00 on Feb 19, 2009 |
# ? Feb 19, 2009 01:34 |
|
Install the sqlite devel libraries for Ubuntu and redo the gem installation. Ruby can either have pure Ruby based extensions, or extensions built on C, much like Python. If you're building a C extension, rubygems will tell you, and if it fails you need to solve it like you would any compiled program. Usually things are C extensions to hook into external libraries and provide a bridge, like sqlite, or if they need to be REALLY fast like the Hpricot XML parser.
|
# ? Feb 19, 2009 02:22 |
|
NotShadowStar posted:Install the sqlite devel libraries for Ubuntu and redo the gem installation. You need the ruby headers, should be in a package called 'ruby-dev'. Otherwise the above holds.
|
# ? Feb 19, 2009 03:43 |
|
Trabisnikof posted:In other news Passenger is awesome, but first load is slow. Sports at 11. It still doesn't get us past using god drat horrible awful terrible capistrano though, which is my biggest grief, so it's useless to me until that day which I'm dreaming of.
|
# ? Feb 19, 2009 23:32 |
|
What is it about Capistrano that you don't like? What is preventing you from just using an alternative? Off the top of my head I can't think of what about using Passenger it is that locks you into capistrano.
|
# ? Feb 19, 2009 23:44 |
|
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. Really, capistrano is unnecessary all you need is to move the files onto the server, perform some rights management on the files create a symlink and that's it. This could all probably be done extremely easily with a bash script. Instead capistrano comes lumbering in with it's billions of lines of code and complete absurdity to "do it for me" which is crap too since I have to go out of my way to tell it not to do things that break the deployment if left alone. I don't even fully grasp the benefit of a server side huge ton bunch of file changes and history of the application, but even that is handled by svn not capistrano. Capistrano is a big piece of crap. <>
|
# ? Feb 20, 2009 01:50 |
|
Nolgthorn posted:It still doesn't get us past using god drat horrible awful terrible capistrano though, which is my biggest grief, so it's useless to me until that day which I'm dreaming of. We don't use capistrano with our Passenger deployment at all.
|
# ? Feb 20, 2009 05:24 |
|
Maybe I just don't get it. It took me a few days of scouring google and the capistrano documentation when I built our initial infrastructure. Now we've been using it for over a year with no problems. One command to deploy and another to migrate is quite nice. I set up my git repository using gitosis and ssh public keys. The webserver and my user on the staging and production servers are in the same group. As is everyone on my development team. Here's my capfile for the perusal. deploy.rb posted:set :application, "appname" Ghotli fucked around with this message at 06:33 on Feb 20, 2009 |
# ? Feb 20, 2009 06:26 |
|
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 |
|
This week I got introduced to the wonders of HAML/SASS and was further blown away by Compass using the Blueprint CSS framework. It took me a while to set it up right because Compass only works with HAML 2.1 (which is an svn version), and I had to use rails 2.1 because with 2.0.2 I couldn't freeze the haml/compass gems and with 2.2.2 mysql wouldnt work. After doing all that I created a sort of complex layout in a couple hours and it looks perfect and consistent in Firefox 3, IE7, Opera and Chrome. I haven't tested in IE6/IE5 and Im not hoping for much, but if it works as good there then this would be the best web design platform ever. Also, using the Blueprint thing normally leads to ugly markup: code:
code:
code:
http://haml.hamptoncatlin.com/ http://acts-as-architect.blogspot.com/2008/11/compass-primer.html
|
# ? Feb 20, 2009 22:53 |
|
Yeah, the HAML/SASS/Blueprint/Compass combination is really fun to work with. If you have to create a smaller static site, staticmatic is pretty sweet and lets you use all of those as well. You can also setup a pretty straightforward capistrano recipe to checkout/build the site on your server too.
|
# ? Feb 20, 2009 23:36 |
|
atastypie posted:Yeah, the HAML/SASS/Blueprint/Compass combination is really fun to work with. If you have to create a smaller static site, staticmatic is pretty sweet and lets you use all of those as well. You can also setup a pretty straightforward capistrano recipe to checkout/build the site on your server too. I've been using webby for my blog for the last several months and it's been great since it's mostly static anyway
|
# ? Feb 21, 2009 00:12 |
|
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. It's bad enough having to re-learn the best way of doing things every six months when I revisit Rails. People keep inventing their own goddamned DSLs for everything and I don't know how they keep them all straight. I guess I like the ERB approach to things: HTML with splashes of Ruby, rather than RUBY EVERYTHING.
|
# ? Feb 21, 2009 06:54 |
|
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 |
|
Operation Atlas posted: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. Ah, how sloppy of me. I think I was thinking of Markaby.
|
# ? Feb 21, 2009 09:53 |
|
savetheclocktower posted:Ah, how sloppy of me. I think I was thinking of Markaby. There does seem to be a trend towards Ruby but Ruby is a really really good high level programming language.
|
# ? Feb 22, 2009 03:54 |
|
Nolgthorn posted:There does seem to be a trend towards Ruby but Ruby is a really really good high level programming language. Well, the "trend towards Ruby" is largely (IMO) because many Ruby/Rails folks can't stand to use anything else and will generally bend over backwards to rewrite perfectly decent and integrate-able existing tools in Ruby. Not Invented Here Syndrome to the max! (For example, God, which is also a terrible, awful name for a piece of software.) Not that other languages don't have NIHS, of course, but it seems to be worse for Rubyists. And to be more on-topic, Haml gets a lot of love from the Rails guys where I work, and they're relatively down to earth, so it must be pretty good I haven't been able to work with it myself yet, still stuck in the Rails 1.2 / ERb maintenance ghetto when I'm on the programming side.
|
# ? Feb 22, 2009 14:43 |
|
atastypie posted:What is it about Capistrano that you don't like? What is preventing you from just using an alternative? Off the top of my head I can't think of what about using Passenger it is that locks you into capistrano. I always would get pissed when I tried to look up documentation (ha!) or wondered why it isn't just a bunch of Rake tasks. I try to ignore it and I scrape by with just enough of a recipe to deploy under passenger. Operation Atlas posted:Try out Vlad. http://rubyhitsquad.com/Vlad_the_Deployer.html Checking this out, thanks.
|
# ? Feb 22, 2009 22:16 |
|
|
# ? Jun 5, 2024 03:12 |
|
Drogadon posted:This week I got introduced to the wonders of HAML/SASS and was further blown away by Compass using the Blueprint CSS framework. I've just been working with this today! A few notes: Here is the guide I used to get up and running with compass and blueprintcss on Rails: http://github.com/chriseppstein/compass-rails-sample-application/blob/81ab7a654754e30f76560018c58b90d05e8200dd/README After that I wanted to vendor the gem, so I added these two lines to my environment.rb: code:
rake gems:unpack Bada bing bada bang boom! In addition I found that when trying to use +showgrid with this gem it was pointing to the grid.png image in the wrong place. I had to change the gem in <gem>/frameworks/blueprint/stylesheets/blueprint/modules/_debug.sass, line 1 and line 4. From: images/grid.png To: /images/grid.png Now everything works, I'm on Rails 2.2.2.
|
# ? Feb 23, 2009 03:50 |