|
KarmaticStylee posted:What rails hosting providers would you recommend? I am looking for something under $30/month if possible. Slicehost for sure. There are a lot of guides out there on how to get up and running with them, and really part of the Rails experience involves figuring out how to set it up. Luckily for you it's gotten a hell of a lot easier over the past few years. I don't miss configuring dispatch.fcgi one bit.
|
# ¿ Apr 28, 2009 20:30 |
|
|
# ¿ Apr 29, 2024 08:37 |
|
NotShadowStar posted:Why is Mechanize needed for a Twitter app? It probably actually logs into Twitter rather than using the API.
|
# ¿ Apr 28, 2009 20:31 |
|
Just to add to that, you don't always have to inherit. I write classes all the time that don't inherit from ActiveRecord. Inheriting from ActiveRecord is when you have a one-to-one class-to-table mapping with your database. If you want to write a class that has other responsibilities, go hog wild. If you want to use { and } rather than do and end you can, but the preferred Ruby style is to use do and end for multi-line blocks and { and } for single line blocks. code:
code:
Finally, not sure who asked it or if it's already been answered, but yes you can craft your own SQL if you need to do something complicated. However, ActiveRecord is powerful and expressive, you don't need to do that very often.
|
# ¿ Feb 1, 2012 15:24 |
|
The .find method has the ability to return either one object or a collection of objects. Most of the time .find isn't used anymore and convenience methods are used instead, but here's an example. Again, the code below is no longer the correct way to do this:code:
code:
code:
code:
|
# ¿ Feb 1, 2012 19:41 |
|
It would probably be a good idea to check out something like http://railsforzombies.org/
|
# ¿ Feb 1, 2012 19:49 |
|
It's split into Model/View/Controller. The framework itself takes care of including all the necessary files so they know how to talk to each other. Let's assume a simple scenario where you have a database table called "people" with columns "first_name" and "last_name". Your goal is to print out a list of these people, ordered by last name, when someone visits http://yoursite.com/people. First the model (app/models/person.rb). This model doesn't need any code because it inherits from ActiveRecord::Base. That means that you automatically get methods like "all" and "find" and "save." However, if you have any heavy duty business logic you want to include it in the model. In our example I'll be defining a method called "full_name" which just concats the first_name and last_name methods. In my example I use "return" and I also refer to "self.", both of which are unnecessary and frowned upon, but they make it easier to understand in this example. code:
code:
code:
|
# ¿ Feb 1, 2012 20:05 |
|
Physical posted:I am at least familiar with MVC methodology and specifically have experienced using it with PHP and Code Ignitor. The major difference between Rails and CI (in my limited experience with an older version of CI) is that Rails practices what's called "Convention over Configuration." Assuming you follow the Rails conventions of putting your files in the right places and naming them the right things (in relation to your database table names, for example) you don't have to explicitly include any files, it's all done for you. In CI if you want to reference a model from another controller you have to specifically say "i'm going to be working with this model" but you don't need to do that in Rails. You can pretty much access anything from anywhere if you know what it's called. Look at the index action in the controller and the index.html template (I forgot to mention that the view would reside in app/views/people/index.html.erb). Rails automatically invokes app/views/people/index.html.erb for the action "index" in the controller "People" because that's the convention. If you wanted to you could render something else. code:
code:
|
# ¿ Feb 1, 2012 20:54 |
|
Check out that Rails for Zombies site I linked, it's supposed to be really good for beginners. Bump this thread if you have any other questions, I'll keep an eye on it.
|
# ¿ Feb 2, 2012 03:14 |
|
I know, I mentioned that above my code block. I wrote the example that way because the Ruby style would be a little confusing for someone who is new to Ruby. Adding the self and return hopefully made it clearer in the example but I would never write real code like that.
|
# ¿ Feb 2, 2012 17:43 |
|
It might be a good idea to use nested resources for that. Here's a screencast about it: http://railscasts.com/episodes/139-nested-resources
|
# ¿ Feb 21, 2012 22:12 |
|
I think I read on Github or Stack Overflow that suppressing the asset log messages is an option that's coming soon.
|
# ¿ Feb 23, 2012 03:31 |
|
A MIRACLE posted:I'm ready to kill myself. Okay not really but my friend/frontend dev guy did a pull request today where he basically rewrote our entire landing page, started using compass / blueprint, and now I'm running into problems with the asset pipeline deploying to heroku. It's gotten to the point where I'm ready to scrap the whole thing and redo it in Sinatra. Also I'm a little hung over because I got day-drunk at lunch, but still. Can anyone point me to info on the stylesheet link tree? I think that's where the problem is, like it's not precompiling a few stylesheets because they aren't in the tree or something. Here's what my log looks like: If you're including an asset directly in a template that's not called application.js.*, application.css.*, or is not an image Rails won't automatically precompile it in production. You either need to require screen.css from application.css, or you need to add it to your list of precompiles in production.rb code:
|
# ¿ Feb 23, 2012 15:17 |
|
Physical posted:How the heck do you get a debugger to work in a Win 7 64-bit environment using eclipse. All of these directions are so vague. You're going to have a hard time finding help for that environment I think. When I develop Rails in windows (which is rare) I use Cygwin for the server. Neither Windows nor any of the IDEs are particularly well-supported, Cygwin takes away a lot of the pain IIRC.
|
# ¿ Feb 24, 2012 15:47 |
|
I'm not totally sure. I don't know a lot of developers that run Eclipse. It seems like most Rails devs run development server via the command line (using Webrick or Mongrel or whatever) and then use their text editor of choice to write code (TextMate seems to be the most popular judging by screencasts, but Vim is up there too). By using these pre-packaged but somewhat poorly adopted solutions you may be setting yourself up to run into stumbling block after stumbling block, is there a reason you're determined to use Eclipse? Edit: Also, #rubyonrails on freenode is a good place to ask for help, there are a lot more people there than there are reading this thread.
|
# ¿ Feb 24, 2012 16:32 |
|
I can see the allure of wanting ruby autocomplete but honestly, there just aren't that many methods to memorize. It's not like PHP where there's no consistency in function naming or argument order. If you want a debugger I highly recommend just running your actual server via command line and dropping the debugger in your code where you need it. I know Eclipse is really popular, I just don't think it's very popular among Rails devs.
|
# ¿ Feb 24, 2012 19:39 |
|
Use an underscore.
|
# ¿ Feb 25, 2012 21:42 |
|
You mentioned earlier that you had access to a *nix box or VM? Honestly I would do my development there, Rails under Windows is painful. I have no idea why it wouldn't be dating your migrations, I've never seen that happen before.
|
# ¿ Feb 27, 2012 03:07 |
|
Same project under *nix, same problem?
|
# ¿ Feb 27, 2012 05:37 |
|
I have never heard of this issue ever, is this a fresh project or something you cloned at your new job? Is this a work issued machine or your own?
|
# ¿ Feb 27, 2012 15:07 |
|
Is this set anywhere:code:
|
# ¿ Feb 27, 2012 17:17 |
|
Physical posted:That is not showing up anywhere in any of the project files. What file is it normally under? I want to put it in there with = true application.rb Open up rails console and type YourApp::Application.config.active_record.timestamped_migrations to see what it's set to. Replace YourApp with whatever your app's module is called in config/application.rb quote:Mac users, what makes up your rails development environment? rails server rvm TextMate github mysqlol
|
# ¿ Feb 27, 2012 22:41 |
|
Do you guys use postgre in production as well or just for development?
|
# ¿ Feb 28, 2012 00:11 |
|
Doc Hawkins posted:When people say "use postgres in development," it's short for "use exactly the same environment in development as in production, by the way use postgres." Do you mind giving me a quick rundown of why it's better than MySQL, or pointing me towards some info about it? MySQL has always just worked for me so I've never really given other solutions much thought.
|
# ¿ Feb 28, 2012 00:47 |
|
I let the generator do it for me, especially because you've been able to write the whole thing from the command line for a few years now.
|
# ¿ Feb 28, 2012 15:22 |
|
Wow I am loving Sublime Text 2. Thanks for the recommendation! Edit: Seriously, how the gently caress is it this fast? If you're a TextMate user you have to give this a try. prom candy fucked around with this message at 04:05 on Feb 29, 2012 |
# ¿ Feb 28, 2012 19:44 |
|
Scaramouche posted:Also that example is as real as the day is long. Make sure you update the thread when you inevitably post the story on Clients From Hell.
|
# ¿ Feb 29, 2012 03:22 |
|
Your association method can't be named something that's already a column in your database. If you want to have something that belongs_to an owner your column should be owner_id. You're basically getting a method collision right now because with active record any field in your database (with a few exceptions) becomes a method on your model, and when you declare an association that also creates methods on your model. So when you type Thingy.owner it doesn't know if you're referring to the association or the value in the DB field. Your issue is completely unrelated to the inheritance.
|
# ¿ Mar 1, 2012 21:08 |
|
A big part of making yourself marketable in web dev these days is understanding front end development. Make sure you're learning javascript concurrently with whatever back-end language/framework you decide on. And I mean really learning javascript, not pasting jQuery plugin examples into your onclick attributes.
|
# ¿ Mar 2, 2012 16:15 |
|
Have you looked into Capistrano? Your set up is a little more complicated than mine but if there's someone out there who's solved your particular problem it's fairly likely that they've done it with Capistrano.
|
# ¿ Mar 2, 2012 19:35 |
|
Shot in the dark, but try gem 'acts_as_archive', :git => 'http://github.com/xxx/acts_as_archive.git', :require => 'acts_as_archive' Alternately, go harass whoever pushed that change as they probably already figured out a fix. prom candy fucked around with this message at 15:45 on Mar 7, 2012 |
# ¿ Mar 7, 2012 15:40 |
|
That seems to be a theme in this thread for you. Edit: Seriously, tell your work to set you up with a proper dev. environment. Alternately, tell your linux lubbin coworkers to put linux only gems into :group => :linux and then install your gems with bundle install --without linux
|
# ¿ Mar 7, 2012 19:06 |
|
He's specified that it should use the Gem found at that GitHub location, and that version of the gem is breaking something in your app. Run the rake task with --trace and you can figure out where it's blowing up. Breaking your co-workers' poo poo with one of your commits is generally considered a faux pas, he should be helping you resolve this.
|
# ¿ Mar 7, 2012 20:02 |
|
Checkout ActiveRecord's update_all method. You're trying to update a number of records, correct?
|
# ¿ Mar 19, 2012 05:10 |
|
Large Hardon Collider posted:Actually just one. The site lists local businesses, each with a number of aspects you can rate, formulated as questions. The questions themselves are stored in the database, and I want to correct a typo in one of them. So you're looking to do the most basic update operation then. Open up your console and do something like. code:
code:
|
# ¿ Mar 19, 2012 14:22 |
|
Migrations are for structure but you can put content operations in there as well. However, that's not really the best way to go. I would put it in a rake task and then run it on your different environments, or just do it manually from the console on your environments. It depends on if you're going to need to reuse the task or not. Will somebody cloning the project for the first time have to deal with this, or is it a case of somebody entering bad data into a production DB?
|
# ¿ Mar 19, 2012 15:18 |
|
Just to clarify, what you've got there is a Hash inside of an Array. @blah.data.class would return Array @blah.data[0].class would return Hash For some reason coming to Ruby from PHP I found distinguishing between Arrays and Hashes took me a long time, probably because in PHP an array is kind of both.
|
# ¿ Mar 20, 2012 16:31 |
|
What does your create action look like? Are you creating the message in a separate messages controller? This pretty much all has to do with when you're setting the value of @messages.
|
# ¿ Mar 21, 2012 05:05 |
|
So we're talking about the case where "!@message.valid? && signed_in?" right? Maybe my memory is wrong but I didn't think render :template ran the controller action. How is @messages getting set for the view? Or are you just calling @user.messages directly in the view?
|
# ¿ Mar 21, 2012 14:14 |
|
Is your view code references @messages or @user.messages? Actually can you paste your whole view (or at least the relevant parts)? Edit: use gist.github.com to save the table-breakage prom candy fucked around with this message at 21:05 on Mar 21, 2012 |
# ¿ Mar 21, 2012 21:00 |
|
|
# ¿ Apr 29, 2024 08:37 |
|
You're going in the right direction, accepts_nested_attributes_for is a good way to build little sub-forms for your child elements. Try this: http://railscasts.com/episodes/196-nested-model-form-part-1
|
# ¿ Mar 26, 2012 05:10 |