10 Dec 2006

Strange behaviour of respond_to in IE

General, rails, ruby on rails posted by Ritu

In recent days i have monitored a very strange behaviour of respond_to in IE.I am sharing my experience in hope that somebody might explain it to me. As i cudnt find anything related to this from my best teacher google :(

I am using edge rails in one of my projects. some where in that i have used respond_to in following way…


def show
respond_to |format| do
format.js {render :partial=>’show’}
format.html {}
end
end

When i checked the response in firefox for html and xml both requests type, it was perfect. But when i checked html response in IE 6 creates a blunder :O.It was returning a js file with the javascript response.

But when i changed the code and placed the html call first and then checked xml call it worked fine in IE too.

def show
respond_to |format| do
format.html {}
format.js {render :partial=>’show’}
end
end

Now can somebody tell me why is this happening and anyone else faced this issue ever?

28 Sep 2006

What do you see a face or an Eskimo?

General, rails posted by Akhil Bansal

eskimo.jpg

14 Aug 2006

Simple star rating in Rails

General, rails, ruby on rails, Technology posted by Ritu

Those who wants to include simple 5 star rating mechanism in their ROR application.Can include a couple of functions in their helper to provide a form a rating field and display the result.Of course no 1/2 ratings can be achieved through this way. One needs to include the below given two function to some helper. And in view inside form tag call…


  star_rating_field("object", "fieldname", options)

Options are location, prefix, active_img, grey_img, hover_img…

For displaying the result of the rating in star images format…call from view


  img_tag_for_star_rating(rating_value,options)

Options are location, active_img, grey_img, hover_img…

Download the function to include in helper from here …I am finding it very difficult to put the code in wordpress without tampering so better to put it somewhere else ;)

Update: the file gets removed everytime.I m trying to out the code here only…


  #General function for star rating
  # Use these function as helpers
  # No half ratings are handled here
  # options can hav ...
  # location=>location of images( you need to have star_active.gif, star_grey.gif, star_hover.gif in this directory or provide names of image file in options)
  # prefix => prefix to append to each ids in DOM for descrimination of more then one star rating in the same page
  # grey_img => name of inactive/grey image of star
  # active_img => name of active image of star
  # hover_img => name of hover image of star
  def star_rating_field(obj_name, field_name, options={:location=>'/images',:hover_img=>"star_hover.gif", :active_img=>"star_active.gif", :grey_img=>"star_grey.gif"})

    # append a hidden field to store value of viz system field
    # this field is to be changed as hidden after testing
    hid = text_field(obj_name, field_name)
    hid_id = "#{obj_name}_#{field_name}"
    pref_id = options[:prefix].nil? ? 'star' : options[:prefix]+'_star'
    img_location = options[:location]
    # set initial value by javascript
    jscript = ""
    jscript += "var a; var v = parseInt($('#{hid_id}').value); for(var i = 1;i"
    img = ''

    # add images to field
    for i in 1..5
      img += "“+’ ‘
    end
      return  img + hid + jscript
  end

  def jscript_for_star_rating(pref_id, img_location)
    jscript = ” function set_star_status(n, id)    {  if( $(id).value != n){ for(var j=1; j”star_active.gif”, :grey_img=>”star_grey.gif”})
    image = ”
    for i in 1..5
      if i ”
      else
        image += “”
      end
    end
    return image
  end

Note:Do remember to include prototype library from script.aculo.us in your page.

UPDATE2:phew…finally trying to add the file again.Hope it work fine this time :( try this=>Star Rating functions

06 Aug 2006

I discovered my true luv-ROR

General, Ruby On Rails resources, Technology posted by Ritu

I went to PHP Meetpup last week… there were some very good presentations ..one on Drupal by Saswata, which was more like a comparison between different Open source CMS. Then there was Prasun’s presentation on “Open Source business Models”. The third presentation was very technical one on Ruby on Rails By Manik (MJ).

When MJ was giving his presentation on ROR, someone asked “Why do you want to adopt ROR in place of PHP, when PHP is easy to code? What we need is get our work done and we can do that in PHP very easily. So why use ROR?”

At that particular moment I discovered my true love for Ruby On Rails. From my opinion coding is not only typing some software on keyboard …I think Programming == Logic. For the people who love to code “It’s all about doing it with Logic”. Following the same old tradition sucks your passion for coding and what you are left with is thousands of lines of code written without any interest just to get your job done. The best part of ROR is that it provides coders the ability to think. Instead of writing each and every query in PHP I can spend time on thinking the best way to design the application because I have ActiveRecord methods to protect me from writing those queries. For ROR its like, if you know about web programming you need not worry about basic things… what is needed is, ‘The Logic’ and the zest to learn all the time. So for those who wants a satisfied client… its ok to use whatever that suits them but for those who wants a “More then satisfied client” and an “even more then satisfied programmer “ the best thing I could suggest is Ruby On Rails.

What else I can say…I love ROR and very soon I am going to wear ROR (planning to get ROR T-shirts;)). I wish I could eat ROR also…Hey that’s a gr8 idea I am next going to invent a dish called Ruby On Rails :D

25 Jul 2006

Automatic Ajaxification With KRJS

General, rails, ruby on rails, Technology posted by Ritu

KRJS plugin developed by Chew Choon Keat could be called an extension to RJS templates by Cody Fauser . In his post KRJS: RJS without messing the Views Keat explains how KRJS can be used to update functionality in views without even touching the views.

Next Page »« Previous Page