|
This is going to sound rather strange, but i'm bored and i fancy writing a rails app that some people will actually download and use. Anyone got any suggestions?
|
# ¿ Aug 20, 2010 20:43 |
|
|
# ¿ Apr 27, 2024 12:42 |
|
Datamapper is pretty awesome guys; yes it involved switching my rails 3.x site from authlogic to devise, but that was minimal . No migrations, define properties once, auto migrate/upgrade... utterly awesome for development. Thought you should know! edit - plus, its faster and much nicer to use than AR.
|
# ¿ Jul 17, 2011 15:06 |
|
Evil Trout posted:I spent almost a year working on a series of dating sites that used DataMapper, and let me tell you it was like pulling teeth. We had to make awful choices like sticking with a version that had known memory leaks or spending months upgrading to the latest version because they changed the API in huge awful ways. Not my experience. The killer features of DM for me are only defining data model once (in the models) and proper o(x) scalability. Also, had issues moving AR to DM and theirc channel was more than helpful, providing that is you use Google and read docs first.
|
# ¿ Jul 17, 2011 16:53 |
|
Stup posted:Been developing in Rails for a few months now and ran into some difficulties with this problem. You're going to do one of two things here. The first is to pull the entire validation down to the model - preferred approach - using a custom validator (http://edgeguides.rubyonrails.org/active_record_validations_callbacks.html 6. Creating Custom Validation Methods) i.e. in the model code:
Alternatively, you can always do @model.errors.add_to_base in your controller, but I'd push the validation to the model...
|
# ¿ Jul 17, 2011 19:10 |
|
Yes, there is; you'd use a custom validator with validates :validationmethod in the model. So, for examplecode:
|
# ¿ Jul 17, 2011 19:59 |
|
Stup posted:This makes sense. I guess my Ruby isn't strong enough and I'm not quite sure how to build my conditional. Would you happen to know any good resources for me to read up on this? Depends what you mean by 'conditional'. You mean your 'question'/'if statement' ? Most of the time when operating across a set your options are either each, map, or inject, depending on what the problem is.
|
# ¿ Jul 17, 2011 23:30 |
|
Stup posted:For example, I can't understand the syntax used here: That's just a short way of doing a single-line loop in Ruby. It's the equivalent of doing code:
For example, for: array = [{:value => "one"}, {:value => "two"}] (an array of two hashes each with a :value element) code:
["one","two"] Which is identical to doing: code:
Best starting point for that kind of thing is the ruby Enumerable docs - http://www.ruby-doc.org/core/classes/Enumerable.html kalleth fucked around with this message at 00:21 on Jul 18, 2011 |
# ¿ Jul 18, 2011 00:19 |
|
enki42 posted:Better still is: Bastard :P yeah, that works
|
# ¿ Jul 18, 2011 18:11 |
|
Stup posted:So I tried creating my own validation. I know it's ugly but please forgive me! My fault. See http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validate - you want validate, not validates, which is used for something completely different.
|
# ¿ Jul 19, 2011 10:31 |
|
Stup posted:So I tried using validate and the error went away, but no errors ever pop up. Can I see the validate code from the model as well? Are you sure the create action still goes through; I.e. is something being persisted to the database? Perhaps call save! rather than save which will create an exception if the save fails? A good way of debugging stuff is using the $ rails console command line to give you effectively an irb within your app environment. This will let you do something like > team = Team.find(:first) #<Team:Object> > team.add_player(Player.find(:first)) #<Team:Object player=#<Player:Object>> > team.save! > either backtrace or false or true You can then use the console to inspect any errors.
|
# ¿ Jul 20, 2011 10:35 |
|
Bob Morales posted:What are some good blogs/articles about setting up multiple front-end web servers with a load balancer (an all free-software Linux solution is preferred)? First thing I'd do is some kind of data retention policy to prune old, unused data. You can't just have a database grow all the time without some kind of attempt to clean it. Apart from the obvious storage concerns, old data is useless data that pollutes your data stores usefulness. My personal thoughts are if you want to go the balancer route properly, i'd look at some other rack servers; thin/rainbows/mongrel - instead of passenger. That way you can split it out - a frontend web server running apache/nginx which is the 'entry point' to your users - feeding out over an internal network to several different balancers using mod_proxy. These balancers can connect to your database server individually. Blogs, not too sure, but that's the approach I use; when using nginx or apache as a simple pass-through for the balancers and a dedicated database box, you're not going to hit capacity on either of those before you have a rack full of balancer servers.
|
# ¿ Sep 27, 2011 09:21 |
|
Bob Morales posted:How do you keep the web servers synchronized? Capistrano can push to more than one server but we have user data (images etc) that aren't in there. I take it we would need to implement some sort of shared storage between hosts? Depending on your level of traffic, your frontend apache / nginx server can 'act' as a CDN for static assets - i.e. images/etc. Your mod_rewrite rule that redirects requests to the balancers is normally only set up to forward to the balancers if the request path doesn't exist relative to the document root. Or use Chef. Or Puppet. Or just use heroku.
|
# ¿ Sep 27, 2011 23:14 |
|
holy moly, ruby 1.9.3 and rails 3.1.1 are a pretty amazing combination, speed-wise, compared to even 1.9.2 and 3.0. I have no proper metrics for this, but the app just feels really responsive, sub~20ms response times for each page request/load, etc. Got a web application up atm on a 512mb ram vmware VM (single core) used by approx 50-60 people at once, on a single thin balancer, and the load is negligible. And that's without caching! I'd love to see a 1.9.3 + 3.1.1 comparison vs a php framework, right now.
|
# ¿ Nov 19, 2011 13:48 |
|
Physical posted:Also what is the deal with always having to inherit form an object? Literally everything in Ruby is an Object. '1' is an object of the String class, 1 is an object of the Fixnum class. Physical posted:Like, how do you know which objects to inherit from? Where is the list at? Right now, those first two parts are really losing me, the missing {} and () sucks too. Why do I have to right end if I can just do } I like the way it looks much better. In the examples given, the models and controllers (Person, PersonController 'classes') build on functionality provided by rails, hence they inherit from ('extend') ActiveRecord::Base class which then provides an ORM around using that object (having it go to the database to retrieve itself, for example, and allowing you to 'save' it, etc). The controller code is called in specific ways with specific prefixes/suffixes etc hence extending from ApplicationController (which extends from some other ActionController::Base, i think). Basically, if you didn't extend these classes, you don't get the functionality of rails. Physical posted:And is the lowercase person the same as the uppercase Person ? code:
|
# ¿ Feb 1, 2012 15:01 |
|
Just throwing this out there... Am I the only one who doesn't like using the generators and just writes the migration and class by hand? It's not hard, self.up, self.down, blank Model < ActiveRecord::Base, etc. It's not that I don't trust generators, i'd just rather learn how to code the stuff a generator does for me, and it doesn't even save that much time
|
# ¿ Feb 28, 2012 09:59 |
|
Use simple-navigation for nav - https://github.com/andi/simple-navigation - and cancan for authorization
|
# ¿ Apr 27, 2012 10:25 |
|
8ender posted:We use simple-navigation on three of our apps and its versatile as hell. I go out for beer with the current maintainer of simple-navigation now and again :P (mjtko, not andi)
|
# ¿ Apr 27, 2012 17:35 |
|
|
# ¿ Apr 27, 2024 12:42 |
|
A MIRACLE posted:That's not so bad. I'm on a team that writes migrations that look like Notwithstanding that that should be a database 'seed' rather than a migration, don't use models in migrations. Like that, at least. http://gem-session.com/2010/03/how-to-use-models-in-your-migrations-without-killing-kittens http://complicated-simplicity.com/2010/05/using-models-in-rails-migrations/ Edit: Also, kill yourself. Then quit.
|
# ¿ Oct 16, 2012 21:41 |