#ruby on rails
15 posts tagged ruby on rails. Clear filter
-
Running my site through an MCP server
The admin area of this site has a second front door: a Model Context Protocol server at POST /mcp. Here is what that takes in Rails — JSON-RPC over one route, a bearer token, and twenty tools that go through the same models as the browser.
-
Change the Default Controller Name in Rails Functional Tests
Rails will infer the controller you want to test from the class name of the test case. For example... class PeopleControllerTest < ActionController::TestCase end will test the...
-
How To Enable IFrame Support on Heroku with Ruby on Rails and Sinatra
This actually has more to do with Rails and/or Sinatra than it does with Heroku. You have to enable IFrame support in your headers explicitly. With Rails you can add this to your...
-
The Best Video About How to Make Money Online
This is one of my favorite videos on the internet. It is what got me interested in Rails and made me work toward the goal of running my own business and hopefully soon, launch my own products....
-
Installing Ruby with RVM without Xcode using CLANG
I am not using the full Xcode package on my laptop. Instead I'm using the command line tools, offered by Apple as a separate and much smaller install. I haven't had too many issues, aside from not...
-
How To Export A MySQL Database to JSON, CSV and XML with Ruby and the ActiveRecord Gem
It's trivial to export data from a mysql database with Ruby and ActiveRecord. All you have to do is establish a connection and define a class that represents the table. require 'rubygems' require...
-
How To Add A Route With A Forward Slash in Params with Rails 3 Application
Use an asterisk in the pattern to match for everything after it. In the example below, date will be available in the params hash as params[:date].
-
How to Add Additional Sub Directories to the Default Rails Test:Unit File Structure
Edit Rakefile in project root Add a new rake test task... E.g., rake test:lib, below everything else in that file... Alternatively, add a task in lib/tasks/ directory and plop in the same code...
-
Color Output with Test:Unit, AutoTest and Ruby 1.9
If you are testing using Test:Unit (rather than RSpec) and you're using Ruby 1.9. colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test...
-
Aliasing Attributes in Ruby on Rails
Alias an attribute with alias\attribute method. The first argument is the name for the new attribute, while the second argument is to identify the attribute that is already defined.
-
Rails 3 Config Auto Load Paths in Application.rb
In Rails 3 files in lib/ are no longer loaded by default. It's a snap to auto load these classes by adding the following line to config/application.rb This is commented out around line 16. Either...
-
Rails Send_File in Production Delivers an Empty File
If you're running Rails in production it will by default be configured to let apache or nginx send files for you. If you're handling file downloads yourself with send\file you will notice that the...
-
Rails Find All by Birthday: How to Find Upcoming Birthdays with ActiveRecord
There are a few ways to solve this problem. However, I think the easiest is to cache the day of the year that the user is born on as an integer. If stored alongside the timestamp we can quickly get...
-
Simple String Concatenation of a Collection Written as a Helper for Rails
At Railsconf last week I took Greg Pollack's online course Rails Best Practices. The interface is gorgeous and the instructions are excellent. One of the lessons involved taking a partial and...
-
Reusing Scopes (Formerly Named_scope) In Rails 3
You can easily chain scopes together in your models. class Article < ActiveRecord::Base scope :ordered, order('position ASC') scope :published, ordered.where('published = ?', true) scope...