Part 2: local clients pushing data to local server with RESTful web services

November 13, 2009

It’s really easy! But only when you know how! Like most stuff is. I was completely confused at the beginning. What does RESTful web services mean? It’s just a convention. You access the web services almost as you would access using a browser.

  • /products gives index.html with products
  • /products.xml renders the xml with products
  • /products/1 renders the show.html of product with id 1
  • /products/1.xml returns product with id 1 as xml
  • and so on. That’s RESTful

If you are using rails, you follow its convention of a controller with the methods index, show, new, create, edit, update, destroy.

To post data to a RESTful controller, you perform a POST to mydomain.com/myobjects.xml with a xml file. Using httparty, it’s like this

post('/diagonses.xml', :query => {:diagnose => { :time => time,
                                    :diagnosis => 'RESTfully in love'}}})

Creating a RESTful Web Service Client

Read the rest of this entry »


Part 1. Deploying to experimental, :at => local

November 11, 2009

I’d like to share my workflow, as it has proven efficient for me. I’m running two ’servers’ locally (!). Hang on, I said it was efficient, even though it surely doesn’t sound like it. The workflow should gain teams of any sizes, in my opinion.

I am developing an app it in rails and it also exposes some RESTful web services,  with_feed :through => :third_party. The third parties aren’t necessarily third parties, as we develop these too, but they are external apps collecting and sending data to my app. Part 2 will cover the creation of dummy clients that send randomish data to the core app.

OK, I will share the script and procedure I did to have a running server locally alongside developing my app. I wanted to have the server running locally, being able to receive request to the web server, testing the app manually, fast. To distinguish this local server (say localhost:3001) from your development server (sat localhost:3000), I decided to name it experimental, for simplicity. This is my workflow cycle

  1. developing, creating migrations and so on, running mongrel at localhost:3000
  2. git commit -am “I commit small changes, often!”
  3. back_to step 2 if more_should_be_done
  4. relaunch experimental server at localhost:3001, continuously receiving WS requests.

git pull and git push is performed frequently as well, but not as frequent as the above.

Read the rest of this entry »


Rails 2.3+ template for creating new projects

September 24, 2009

I’ve been working with ruby on rails for the last few months and it’s been lots of ups and downs to me. It’s a learning curve and you just have to stand tall through the first frustrating weeks cursing the magic behind that you don’t understand. At least for a hard core java, spring, hibernate developer like myself, spoiled with great IDE support, which ruby lacks (It’s improving, with RubyMine, which I’m using,  a “clone” of IntelliJ IDEA). But then it becomes better, a lot better!

Templates

Kind of what AppFuse was supposed to provide the java maven community (what’s happening with this? I like the initiative!), the template runner of rails (version 2.3+) is supposed to help you set up your project with useful libraries, as authentication, test frameworks etc. No need to talk to much about it, I’ve created one that you can see for yourself, http://github.com/oma/rails-templates !

Read the rest of this entry »