Showing posts with label Rails. Show all posts
Showing posts with label Rails. Show all posts

Sunday, April 29, 2012

Starting off with Rails 3.2.2 on Ubuntu 11

After a long time, I picked up to build a web application for a friend. I havent worked in web apps for about 6-8 months now, and was quite rusty.

Ruby on Rails was a natural choice. However, when I issued the "gem update" it turned out that rails is on 3.2.2 these days, which means there has been at least 4 releases since I last worked with rails.

I typically work in a way that learning happens while working only.  Therefore, I just started building a new application and built a default scaffold (I know, its  an old habit of testing installation using scaffold)... scaffold generated, which means that the backward compatibility is still alive. Server started.. and bang, launched chrome to see how localhost:3000 looks like...

it bombed... there was this "ExecJS::RuntimeError" staring at my face...

It turned out that Ubuntu is the culprit and needs nodejs to be installed as a JS runtime engine is required and by default Ubuntu doesnt provide one.

after "sudo apt-get install nodejs", its all smooth and shiney...

Will share further...

Friday, July 23, 2010

Developing a Rails application using an existing database

This is the latest challenge for me. A database exists with real data in there, and I have to develop a rails application around that.

Initially we needed the basic CRUD screens for some tables.  Being lazy (i m really proud of that), I set out finding if there a solution that generates the forms (read views) for the existing tables/models.

I have already managed to generate models/schema.rb using another gem. This is called magic_model.  Read more about that here

Then google helped me find this another gem called scaffold_form_generator which generates the necessary views/forms for a given model.  However, there need to be some improvements required on that (I think).  perhaps I would contribute something (if I find out enough on how to do that)

Well, for the moment, I am struggling with handling of the missing special meaning column from the legacy tables. Will continue writing on this...

Wednesday, July 21, 2010

Making rails talk to SQL Server Express Edition

I had zero exposure to sqlserver before today. With the help of a dba and google :) I finally achieved the communication.  Here's what I did to achieve this -

Make an odbc connection - pointing to the db server, preferably make a sql server authentication user

Install the following gems
  1. activerecord-odbc-adapter (2.0)
  2. activerecord-sqlserver-adapter (2.3.8)
  3. dbd-odbc (0.2.5)
  4. dbi (0.4.5)
  5. deprecated (2.0.1)

Further, I copied odbc.so and odbc_utf8.so files from http://www.ch-werner.de/rubyodbc/i386-msvcrt-ruby-odbc.zip to .../ruby/1.8/i386-msvcrt even though exact directory was not found in the path. So, the files were eventually copied to ...\Ruby187\lib\ruby\1.8\i386-mingw32

My database.yml file looks like this -

development:
  adapter: sqlserver
  mode: ODBC
  dsn:
  username: myUserName
  password: myPassword



Wednesday, May 21, 2008

Getting Started with ActiveScaffold

Recently I returned to my rails env to do some more experiments (which might be used for a future project)

To start with, I have seen a bit of active scaffold stuff and was very impressed with it originally already.  In the meantime, rails 2 have arrived.  Quite a few things have changed and I was thinking that it might have an effect on the overall picture of active scaffold also.

However, checking up on railsforum etc brought out that not much effect has gone down to active scaffold kind of plugins from rails 2.

Starting up active scaffold is really easy as they say on its website also...

try it here... www.activescaffold.com It turned out to be really simple to initialize yourself with it. 

Searching a bit more I came across a few tutorials -

Tutorial from Active Scaffold guys

Another one from someone like me, experimenting with activeScaffold...

AkillesBlog » Blog Archive » Ruby on Rails: Experimenting with ActiveScaffold   
Blogged with the Flock Browser

Friday, March 28, 2008

config for capistrano

Preparing a deployment of an app
  1. Changes for fcgi configuration in public/.htaccess
    1. Comment the fcgi handler (found in initial few lines of the file)
    2. Change the dispatch.cgi reference to dispatch.fcgi (last few lines of file)
  2. In public/dispatch.fcgi change the shebang line to say something like this
    1. #!/usr/bin/env ruby
  3. Make sure everything is committed. (svn ci)
  4. capify the environment (capify)
  5. run rake configure_for_svn (assuming that the svn.rake task has been created already)
  6. edit config/deploy.rb to adjust values appropriately
  7. run cap deploy:setup
  8. On the remote server, copy $HOME/railsapps/config/database.yml.production to $HOME/${appdir}/shared/config (create target dir if not present). The $HOME/{appdir} should have been created by deploy:setup
  9. Since its the first time deployment, run cap deploy:cold
  10. Next time onwards, when you have to deploy, launch cap deploy:migrate

Saturday, March 22, 2008

Better Cross-Site Request Forging Prevention

Very useful piece of information about the changes from rails 1.x to 2.x.  Since I was following the Agile ... with rails book (which is on rails 1.2.3), I got trapped with this problem.

Few new things for me, the concept of Cross-site request forgery and that rails 2 already handles it in the framework.  I got to this article through www.railsforum.com  and I have to say I am impressed.

What's New in Edge Rails: Better Cross-Site Request Forging Prevention

Providing such useful features built inside the app framework is really intuitive.

Way to go rails... :) 

Friday, March 21, 2008

Saturday, March 15, 2008

My new domain is up and running...and supports rails too...

Finally, after a day and a half of my ordering/starting the process of getting my own domain/site, its up and running.

The dns entries for blogs are set up, the subdomains are set up, and a very basic home page is also up and running. Check it out here... www.sraghav.in

The mail address is going to change forever, I guess. Now onwards, my mail address is going to be on this new domain, instead of something or other at gmail or yahoo... Always hated the fact that I cant get my easy and favourite name to become my mail id... Finally, I get it... :)

The dns configuration for blogs is one sweet thing. I have to appreciate the way blog hosters like blogger and wordpress (to name a few) allow you to call your blog something or other in the browser url, and still happily allow the stuff to be hosted at their site. Now, my blogs are all named according to my wish on my domain.. e.g. techaghav.blogspot.com is now going to be called tech.sraghav.in

I am yet to read more on dns record types and how they actually work behind the scenes, but I understood that you need to create a CNAME (Canonical Name) record in your dns server for the target server (blogger). This will redirect the incoming request (coming at sraghav.in) to target server (blogger) without reflecting the redirection to the source browser. so the browser still thinks that its talking to .sraghav.in while the dns entry makes it talk to .blogspot.com

Love the technology behind this.

My web hosting company, railsplayground.com allows ruby on rails hosting as well. And, that was my primary reason to choose them over other web-hosting providers. Not so costly and still nice services for a basic rails deployment/hosting service. They provide ssh access and subversion access and what not. Almost everything I could think of as a developer, looking for a foothold in rails. Cool people. :)

Saturday, March 8, 2008

Improved Gutsy for 6710b

Going through a few Ubuntu forums, it turned out that many of the initial glitches around Gutsy installation for HP6710b have been removed.

My installation was originally an upgrade from Feisty, a very troubled and hacked one at that. So, I thought why not try to give it a clean shot and get a fresh copy of Gutsy installed on my laptop.

I dared and I like the results already. Few features -

Though I had to spend some time to configure a few things again from scratch, it looks and works like a much better system than it used to.

After my fresh installation, I had initial trouble with installing rails. There this page helped. Though it talks about installation on FreeBsd, it worked perfectly on my Gutsy.

Then I had some trouble with initial password of root user on MySQL. For some reason, after the initial installation, I could not go in mysql environment through any means at all. Then again, googling and ubuntu forums helped out. This page helped me through that.

Finally, when I was installing Eclipse to be able to work faster/better with rails, I came across the fact that the standard Eclipse package from Ubuntu, does not come with any java runtime environment. I tried downloading and using Sun Java but that didnt turn out very well.

Later I found that Synaptics has a cunning little feature. On a right click on a package name, there is a option for "Mark Recommended For Installation". Once I clicked on that, it selected about 15 more packages and this time managed to get all the required stuff for Java as well.

Surprised as I was at the intuitiveness of the package management system, I felt it should hae done the same to start with. Anyway, its fine now. Took some time, but working great now. :)

IDE for working with Rails

For some time now, I was looking for the right kind of IDE to work with ruby on rails. Googling for this helped but not much.

Eventually, I came across this post somewhere which mentioned RadRails. This is a module from Aptana development studio.

In addition to the fact that this is a component of the Aptana dev suite, this component is available separately as a plugin for Eclipse as well.

And installation and configuration come very very simple. In a running version of Eclipse (I have Eclipse 3.2), look for a remote installation site. Few simple questions about which package to install etc. and you have the plug-in installed.

Here's the url to enter in the Eclipse remote update site...

http://update.aptana.com/update/studio/3.2/ => For Aptana tools in general
http://update.aptana.com/update/rails/3.2/ => For RadRails Plugin

And it works like a charm, really. After installation, you can create a new rails project from within Eclipse GUI as well, in addition to your favourite command line methods.

Starting a server, generating components (controller, model etc..), its all possible from the GUI.

I personally like the GUI and the syntax highlighting the most.

Sunday, March 2, 2008

An interesting day of RoR programming...

Got hands dirty with quite a few things in and around RoR.

Started with building the demo application with projects and tasks.. and as the iterative model says, kept adding to it. By the time I realized, I covered quite a few basic concepts of Rails.

Got stuck at some places, and hence my first experience of RoR IRC chatroom. Lovely thing, and really helpful people. Cant thank enough. It seemed as if someone could learn a few things just by reading the discussions only... :)

And, I hope to make some progress on my LMS project as well.

Here's my collection of useful URLs from today's session.

Useful Links around the web...
  1. Rolling on with Ruby on Rails
  2. Rolling on with Ruby on Rails (Part 2)
  3. On Ruby on Rails dot org
  4. Rails Database Validations-1
  5. Rails DB Validations-2
  6. RESTful Design
  7. Oracle's tutorial on RoR
  8. RoR API Docs
  9. www.pastie.org
  10. On Drop Down Menus

Wednesday, February 27, 2008

Another Open source initiative...

I am starting to think of joining another open source project on RoR. Its basically a helpdesk and workflow management solution, which would be totally web based.

I have used Peregrine for quite sometime now, and therefore have a view. I feel that there are some things in the tool that can be improved and therefore the idea. Another guy in US is also working on the topic.

Currently its hosted at rSupport.googlecode.com

Friday, February 22, 2008

Registered at Ruby forge

The Library Mananagment System project has been registered at RubyForge. You can access the default project page at http://rubyforge।org/projects/lms
.

In coming days, I am going to explore more about the project setup on ruby forge and then update accordingly. Right now, the default virtual host that we have got is called http://lms.rubyforge.org, but it really is the default page.

Would update more, perhaps post the few pages that I have thought of on the wiki there.

Thursday, February 21, 2008

DataWarehouse with Ruby on Rails

Recently joined www.rubyforge.org. Wish to join a few projects on similar direction.

While browsing through I found a project they call "ActiveWarehouse" using Ruby on Rails. Pretty interesting for me, since I come from Warehousing background myself.

I guess, I am going to read more about it and probably join the project. See if I can contribute something.

Wednesday, February 20, 2008

Library Management System : Ruby on Rails

Well, I want to learn some more of rails and ruby (as much comes along).

And so I thought of building a tiny little web application to build a library management system based on rails and mysql.

The idea is that, it would be a web based application to manage the library from an staff member's point of view. At a later stage, there would be an additional viewpoint from the library visitor, to search for books, request for issue etc...

I also intend to build a page which could be used to issue out or receive books (as a library transaction).

Here is a summary of what I have thought this application would do.. to start with...
  1. Keep stock of books
    1. multiple copies of book allowed
    2. Allow searching for books in library
    3. search on meta tags
      1. Title
      2. description
      3. author
  2. allow books to be issued out.
    1. keep track of date of issue
    2. Expected date of return
  3. Administration
    1. Allow to add books
    2. Rename, replace, add remove copies etc.
  4. Reports
    1. Books overdue on a given date
    2. Members with overdue books
    3. Books that are most probable to go overdue
    4. Members most responsible for overdue books
    5. etc...

Well, thats the very first stage of requirement thinking that has been done.

Rails Tutorial...

Looks like I found another interesting rails tutorial...

http://www.meshplex.org/wiki/Ruby/Ruby_on_Rails_programming_तुतोरिअल्स

Monday, February 11, 2008

Rails fixed

After some delay on this item, I managed to spend some time on my Ubuntu system.

As it turned out, the rails env was in fact broken due to my mistake. Many versions of rails/ruby installed over period of time. From Ubuntu package management system, from Rails, ruby website. Many versions of gems etc...

So, I had to do a bit of cleaning up. In fact a lot of cleaning up. Removed ruby from Ubuntu packages perspective altogether. All of it. Removed rails from Ubuntu packages as well.

Then I got the latest ruby source code from Ruby-Lang.org and did the basic compilation. Nothing had to be configured for ssl or anything else. It worked like a charm. Lovely.

However, if you have some system running in production on rails, you better read a bit more on rails 2 before migrating to it. I managed because I am still playing around, and nothing is really running that is of production value. :)

It has quite some changes that do NOT fit in with rails 1.2.3 regime. Some of them are here Whats new in Rails 2

good luck :)

btw, found two interesting blogs on rails... adding them to fav links...