Search
Categories
- Deployment (4)
- Development (63)
- Gems and Plugins (4)
- News (2)
- Projects (4)
- Testing (3)
Most Popular Tags
activerecord architecture collections css database date and time debugging design design patterns DRY ebooks fixtures floating-point numbers formatting framework front page global variables helpers I18n introductory launchpad meta-information migrations model multiplicity mvc MySQL partials production rails 2.0 rails 2.1 Rails 2.2 regular expressions routing rss ruby security setup sql UI upgrading user management validation xml xml builder
Tag Archives: introductory
Database Independence
Rails allows you to abstract your code away from the underlying database platform through two facilities: migrations, which allow you to create, manipulate, and populate tables through code; and object-relational (O/R) mapping, which allows you to deal with objects and relationships, not tables. Continue reading
Scaffolding in Rails 2.0
Scaffolding is one very useful part of Rails. It allows you to quickly test your application without having to write a lot of code–most of it is standard boilerplate code anyways! With Rails 2.0, you may have noticed that dynamic … Continue reading
Global Constants
How can you create application-wide constants in your Rails code? The Rails wiki cites four methods; we prefer adding constants to environment.rb. This method is easy, and allows you to access your constants from anywhere in your application. Continue reading
Redirecting in Rails
Rails provides a convenient function called redirect_to which you can use to redirect the browser–no Javascript or meta-tag required! You can redirect to an action (even specifying parameters like an ID), or to the previous page, or to a relative or absolute URL. Continue reading
Missing Attribute: foo
Have you ever gotten the cryptic message Missing Attribute: foo in your code? Rails looks for this attribute in your model, and in the database. It might be that you’re trying to access an attribute that you didn’t select! What’s the solution? Use find_by_sql to add that attribute into your find call. Continue reading
Undefined Method Foo
Sometimes, you add an attribute to a class, but when you try and access it, it tells you that the method is undefined. What’s going on? In this article, we discuss a bit about how Rails searches for things (database and code). The answer is probably that you forgot the getters and setters for that attribute! Continue reading
Posted in Development
Tagged activerecord, attributes, debugging, framework, introductory
Comments Off
Image_Tag and Link_To Helpers
All websites face an issue of: how can I refer to my images in a way that won’t break if I move my site to a new location? Image_Tag helper to the rescue! Similarly, how can you write links to specific controllers and actions, so that if you change things around, the site won’t break? Link_To to the rescue! These helpers provide simple, easy-to-use functionality to help keep your site DRY. Continue reading
Hello Rails! Autopsy – Smart MVC
Rails enforces separation of model, view, and controller code. Most tutorials encourage you to make a single controller per model. But there’s a smarter way you can use MVC–you can create one controller per user group. This gives you an easy, intuitive model of how users access your application, and provide all the logic per user-group in one location. Continue reading
Validation 101
Data validation is crucial to web applications–especially e-commerce applications, where money is involved. Bad data can destroy the usefulness of (or even shut down) an application! What’s more, validation needs to be centralized–you want to keep your validation in one … Continue reading
When New Fails
Sometimes, you say @foo = Foo.new(…) and then @foo.save. But it doesn’t save! In fact, creating the new instance failed! What’s going on? One possibility is that @foo is nil (so it wasn’t created properly). Another possibility is that @foo.id is nil–which means @foo failed validation! Continue reading
Posted in Development
Tagged activerecord, debugging, introductory, new keyword, validation
Comments Off