Blog

Jun
23

Getting RVM and Textmate working together

Posted by Michael Cindric in development | No Comments »

Since RVM works its magic by manipulating your shell’s environment, Textmate can’t know what version of ruby you’ve activated using RVM. This is a headache for developers. Fortunately there’s a quick fix in new versions of RVM.

For info on how to fix your textmate have a read here

Feb
12

The problems with classic styles of Project Management

Posted by Michael Cindric in Business, development | No Comments »

The constant battle l have faced in this game is dealing with old styles of project management still being used today. Some clients and businesses just don’t understand that its not in their best interest to work like this.

I came across a very smart story explaining why this is not the way to go and l think it explains it best.

ProjectManagementSummary The problems with classic styles of Project Management

Courtesy of http://www.ssw.com.au

Sep
29

When to use Nested Controllers in your Rails apps

Posted by Michael Cindric in development, ruby on rails, Tutorials | 2 Comments »

Nested controllers are great. I don’t care that they have a stigma attached to them they work well and make sense especially if your rails application has a Admin section for example. This allows you to easy separate the admin logic into its own controllers etc keeping your code clean and easy to manage.

So thats what we are going to do for this example.

Step 1. Create your admin controller

You can use whichever process works best for you, but for this we are going to use script/generate:

 ./script/generate controller admin

Step 2. Create your user controller

You can use whichever process works best for you, but for this we are going to use script/generate:

 ./script/generate controller admin/users

Step 3. Check to ensure proper inheritance

The nested users controller should look something like so:

class Admin::UsersController < ApplicationController
end

Step 4. Create the Routes

The nested users controller should look something like so:

map.namespace :admin do |admin|
  admin.resources :users
end

Before rails 2+ you had to do like like we have below. Personally l don’t mind it makes it a little easier to read but either option works fine

map.resource(:admin) do |admin|
  admin.resources(:users, :controller => 'admin/users')
end

Step 5. Wait there is no step 5 your done

Now when you need to link to any of these actions its very simple keeping in mind that users is nested under the admin controller so all you have to do to create a link that goes to the index action on the nested users controller is add the admin prefix before

 link_to "Users", admin_users_url

The same applies when you are wanting to link to the show action of users all you do is loose the “s” on users as you would normally

 link_to "View User", admin_user_url(@user)

You can see a list of all the routes you have available to you by going to the root directory of your project in terminal and typing

rake routes
Sep
24

Scoping UserSession with Authlogic

Posted by James Kong in Uncategorized | 9 Comments »

I like using subdomains to create a more personalised web application experience for the user. Having their own URL to access the application allows them to feel a sense of ownership. There are many ways you can do this(click here for one) but I specifically want to look at scoping your user sessions so that users cannot login to other user’s accounts. Doing this with AuthLogic is surprisingly easy.

Assuming you subdomain names come from an Account model, add this line of code.

   class Account < ActiveRecord::Base
   authenticates_many :user_sessions
end

In your UserSessionController you can now scope your user sessions to the account.


class UserSessionsController < ApplicationController

    def create
       @user_session = @current_account.user_sessions.build(params[:user_session])
       if @user_session.save
          flash[:notice] = "Login successful!"
          redirect_back_or_default dashboard_path
        else
          render :action => :new
        end
    end
end
Aug
19

iPhone application intergration with Web Application

Posted by Michael Cindric in development, iPhone, open source, ruby on rails | No Comments »

We are working on integrating an iPhone application with a Ruby on Rails web application. Its actually not that hard, the ObjectResource framework which was developed by Ryan Daigle. It works really well and allows you to easy interact with your rails application with little hassle.

Ill post more about this soon

Jul
29

Lowpro + prototype and Firefox 3.5

Posted by Michael Cindric in development, javascript, lowpro, open source | No Comments »

So it turns out lowpro is broken in the latest Firefox. Anyways DanWebb has released a fix for this which you can read more about here.

Now this didn’t solve my issues all together. I ran into an issue as the JavaScript was loading before the page was completely loading and thus the behaviours were not been added.

So the solution is to add the following

Event.observe(window, 'load', function() {
  Event.addBehavior({
    // assign behaviors
  });
}

That way the behaviours don’t get added until after the DOM has fully loaded.