Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 16:59:00 GMT)

Adding AJAX to your existing RAILS app

Posted by Sat, 02 Apr 2005 07:23:35 GMT

As of Rails 0.11.0, the Rails team has added Ajax support into the framework. Tha’ts right, you don’t need to spend a bunch of time reading through the Ajax fundamentals to get it integrated into you application. The Rails team has made this very simple to utilize.

First of all, make sure you have at least Rails 0.11.0 (about a week old as of today). Next, open up one of your rhtml files (example: standard-layout.rhtml if you followed one of the cookbook tutorials).

Add the following line inside the <head> of your html file.
  &lt;%= define_javascript_functions %&gt;

Now in one of your controllers, add your new method.

  def myrandom
    render_text SomeModel.gen_random(10)
  end

In this example, SomeModel is a model that has a method called gen_random which returns a random alphanumeric string 10 characters long in this case (was used in rubyurl.com).

The last piece is to add the following to my rhtml file:

&lt;div id="myrandom"&gt;x&lt;/div&gt;

&lt;%= link_to_remote "Generate Random", 
    :update =&gt; "myrandom", 
    :url =&gt; { :action =&gt; "myrandom" } %&gt;

Now, you should be able to run your RAILS app and it will display a button for me and when I hit ‘Generate Random’ it replaces the <div> content with the random string.

Yep, that’s all it took to add a non page refreshing action to your script. Of course you can do a lot of cool things with AJAX and this wasn’t one of those cool things… just a quick example. :-)

Adding AJAX to your existing RAILS app

Posted by Sat, 02 Apr 2005 07:23:00 GMT

As of Rails 0.11.0, the Rails team has added Ajax support into the framework. Tha’ts right, you don’t need to spend a bunch of time reading through the Ajax fundamentals to get it integrated into you application. The Rails team has made this very simple to utilize.

First of all, make sure you have at least Rails 0.11.0 (about a week old as of today). Next, open up one of your rhtml files (example: standard-layout.rhtml if you followed one of the cookbook tutorials).

Add the following line inside the <head> of your html file.
  &lt;%= define_javascript_functions %&gt;

Now in one of your controllers, add your new method.

  def myrandom
    render_text SomeModel.gen_random(10)
  end

In this example, SomeModel is a model that has a method called gen_randomrubyurl.com).

The last piece is to add the following to my rhtml file:

&lt;div id="myrandom"&gt;x&lt;/div&gt;

&lt;%= link_to_remote "Generate Random", 
    :update =&gt; "myrandom", 
    :url =&gt; { :action =&gt; "myrandom" } %&gt;

Now, you should be able to run your RAILS app and it will display a button for me and when I hit ‘Generate Random’ it replaces the <div> content with the random string.

Yep, that’s all it took to add a non page refreshing action to your script. Of course you can do a lot of cool things with AJAX and this wasn’t one of those cool things… just a quick example. :-)

Lucas shares his secrets

Posted by Sat, 02 Apr 2005 00:54:04 GMT

Lucas Carlson has posted on his blog an entry called, How to Make a Living Programming in Rails which pretty much explains the main steps that you should take when you want to be a freelance developer in the open source world. ( I don’t know if these same base rules work in the proprietary world..so I can’t say if it does or not).

A few things to add to his top 5 list would be to participate in the mailing lists (google indexes that) and get your name out there. In my PHP/PostgreSQL consulting career, many people come to me because they found a code sniplet, or a mailing list archive where I answered a similar question from someone else… these all leads to contacts and potential customers.

As my Ruby/Rails experience is still growing but I have picked up on some of the fundamentals fairly quick, I have been working on a few client projects and one product that will be launched by my company, PLANET ARGON sometime in May or early June.

I hope to meet Lucas in a few weeks when he presents Ruby/Rails at FreeGeek. It’s good to see that there is an active development group in the Portland, OR area.

Lucas shares his secrets

Posted by Sat, 02 Apr 2005 00:54:04 GMT

Lucas Carlson has posted on his blog an entry called, How to Make a Living Programming in Rails which pretty much explains the main steps that you should take when you want to be a freelance developer in the open source world. ( I don’t know if these same base rules work in the proprietary world..so I can’t say if it does or not).

A few things to add to his top 5 list would be to participate in the mailing lists (google indexes that) and get your name out there. In my PHP/PostgreSQL consulting career, many people come to me because they found a code sniplet, or a mailing list archive where I answered a similar question from someone else… these all leads to contacts and potential customers.

As my Ruby/Rails experience is still growing but I have picked up on some of the fundamentals fairly quick, I have been working on a few client projects and one product that will be launched by my company, PLANET ARGON sometime in May or early June.

I hope to meet Lucas in a few weeks when he presents Ruby/Rails at FreeGeek. It’s good to see that there is an active development group in the Portland, OR area.

Mac the right way to go?

Posted by Wed, 30 Mar 2005 21:02:17 GMT

Curt Hibbs announced his blog this morning and it was due to a post on Loud Thinking, where he mentioned a Paul Graham post about the Mac adoption amongst hackers. In David’s post he made the following comment, While I can certainly understand the reasons why some people go with Linux, I have run all but dry of understanding for programmers that willfully pick Windows as their platform of choice. I know a few that are still stuck in the rut for various reasons — none of them desire.

Curt responded in his personal blog on this as David had shut off comments on the entry after getting a bunch of harsh responses. Curt made a few good points on how David’s comments were not very fair to people as he made a lot assumptions that yes people do get stuck working in a Windows environment, but to proclaim that none of it is from desire is kind of missing the bigger picture. If people are using Ruby/Rails on any system is better than not at all. I would assume that the majority of people using Rails are probably Windows users and it’s another good way to lure people off of the Microsoft boat.

Don’t get me wrong, I think it’s pretty and all, but if you have ever seen my desktop, you’d know that I never see my desktop unless you see the background coming through my transparent terminal screens. So, what does OSX offer me as a Linux user that I don’t already got? The only thing that I was able to think of was, Safari for testing and Photoshop? I’m not a designer, so thats a non-issue for me.

I have a good friend who is working in a .NET world and is learning Ruby/Rails. He is able to migrate to Linux for the cost of a few CDRs and he’s already playing around with Linux for the first time. He cannot abandon his x86 hardware for Apple hardware overnight and I think this holds true for most people.

However, I would never tell him that he is a bad programmer for choosing to work in the Windows world, it’s not something that I wanted to do anymore, but I made the change on my own. I hope that David is better able to explain why he felt it necessary to condem a huge portion of the work force, who are taking interest in his work. Don’t piss them off, they might take that into consideration when choosing to use your business or not.

Having said that, if you use any computer, you suck. :-p

Besides, when I think of a typical Mac user, I think of Best of Show.

Best in Show

Disclaimer: As always, I forgot to hit the sarcasm button

Mac the right way to go?

Posted by Wed, 30 Mar 2005 21:02:17 GMT

Curt Hibbs announced his blog this morning and it was due to a post on Loud Thinking, where he mentioned a Paul Graham post about the Mac adoption amongst hackers. In David’s post he made the following comment, While I can certainly understand the reasons why some people go with Linux, I have run all but dry of understanding for programmers that willfully pick Windows as their platform of choice. I know a few that are still stuck in the rut for various reasons — none of them desire.

Curt responded in his personal blog on this as David had shut off comments on the entry after getting a bunch of harsh responses. Curt made a few good points on how David’s comments were not very fair to people as he made a lot assumptions that yes people do get stuck working in a Windows environment, but to proclaim that none of it is from desire is kind of missing the bigger picture. If people are using Ruby/Rails on any system is better than not at all. I would assume that the majority of people using Rails are probably Windows users and it’s another good way to lure people off of the Microsoft boat.

Don’t get me wrong, I think it’s pretty and all, but if you have ever seen my desktop, you’d know that I never see my desktop unless you see the background coming through my transparent terminal screens. So, what does OSX offer me as a Linux user that I don’t already got? The only thing that I was able to think of was, Safari for testing and Photoshop? I’m not a designer, so thats a non-issue for me.

I have a good friend who is working in a .NET world and is learning Ruby/Rails. He is able to migrate to Linux for the cost of a few CDRs and he’s already playing around with Linux for the first time. He cannot abandon his x86 hardware for Apple hardware overnight and I think this holds true for most people.

However, I would never tell him that he is a bad programmer for choosing to work in the Windows world, it’s not something that I wanted to do anymore, but I made the change on my own. I hope that David is better able to explain why he felt it necessary to condem a huge portion of the work force, who are taking interest in his work. Don’t piss them off, they might take that into consideration when choosing to use your business or not.

Having said that, if you use any computer, you suck. :-p

Besides, when I think of a typical Mac user, I think of Best of Show.

Best in Show

Disclaimer: As always, I forgot to hit the sarcasm button

Older posts: 1 ... 40 41 42 43 44