Wednesday, May 26, 2010

When I was at SPURTHI-2007


Wednesday, February 11, 2009

IMAGE UPLOADING

Image uploading is easy in ruby on rails by using attachment_fu plugin

To install attachment_fu
ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/attachment_fu/


Then u need to design table in migration like

here we will take user images
class CreateUserImages < ActiveRecord::Migration
def self.up
create_table "user_images",:force => true do |t|
t.column "user_id", :integer
t.column "primary", :boolean
t.column "created_at", :datetime

# Required attributes for attachment_fu plugin
t.column "filename", :string, :limit => 255
t.column "path", :string, :limit => 255
t.column "content_type", :string
t.column "size", :integer
t.column "width", :integer
t.column "height", :integer
t.column "parent_id", :integer
t.column "thumbnail", :string
end

def self.down
drop_table :user_images
end
end


In model we need to customize validations

class UserImage < ActiveRecord::Base
belongs_to :user

has_attachment :content_type => :image,
:storage => :file_system,
:min_size => 0,
:max_size => 1.megabytes,
:resize_to => '640x480',
:thumbnails => { :medium => '200x200', :small => '80x80', :tiny => '40x40' }

# Override the default AttachmentFu error messages.
def validate
if filename.nil?
errors.add_to_base("You must choose a file to upload")
else
# Images should only be GIF, JPEG, or PNG
enum = attachment_options[:content_type]
unless enum.nil? || enum.include?(send(:content_type))
errors.add_to_base("You can only upload images (GIF, JPEG, or PNG)")
end
# Images should be less than UPLOAD_LIMIT MB.
enum = attachment_options[:size]
unless enum.nil? || enum.include?(send(:size))
msg = "Images should be smaller than 1 MB"
errors.add_to_base(msg)
end
end
end
end


And in User model

class User < ActiveRecord::Base
has_many :user_images


def primary_image
user_images.find_by_primary(true)
end
end


Here in controller only to display and create

class UserImagesController < ApplicationController
def new
@image = UserImage.new
respond_to do |format|
format.html
end
end

def create
# Required for Windows machines. Uncomment if you using Windows
# sleep(1)
user_data = {:user => current_user, :primary => current_user.images.empty? }

@image = UserImage.new(params[:image].merge(user_data))

respond_to do |format|
if @image.save
flash[:success] = "image successfully uploaded"
format.html { redirect_to(edit_user_path(current_user)) }
else
format.html { render :action => "new" }
end
end
end
end


And in new.rhtml

Current Primary Photo


<% if(@current_user.image.nil?) %>
<%= image_tag("default.png") %>
<% else %>
<%= image_tag(@current_user.primary_image.public_filename(:medium)) %>
<% end %>

Upload a new photo


<%= error_messages_for :image %>

<% form_for(:image, :url => user_images_path,
:html => { :multipart => true }) do |f| %>

Select a photo to upload

Photo: <%= f.file_field 'uploaded_data' %>
<%= submit_tag 'Upload Photo' %>
<% end %>


Follow the steps
Rake db:migrate
Then Script/server


If u want ur own validation to image then here are some key points
has_attachment(options = {})

* :size
o Range of sizes allowed.
o (1..1.megabyte) is the default. This overrides the :min_size and :max_size

* :resize_to
o Used by RMagick to resize images.
o Pass either an array of width/height, or a geometry string.

* :thumbnails
o Specifies a set of thumbnails to generate.
o This accepts a hash of filename suffixes and RMagick resizing options.
o This option need only be included if you want thumbnailing.
o :thumbnail_class
o Set which model class to use for thumbnails.o This current attachment class is used by default.

* :path_prefix
o path to store the uploaded files.
o path to store the uploaded files.
o Uses public/#{table_name} by default for the filesystem, and just #{table_name} for the S3 backend.
o Setting this sets the :storage to :file_system.

* :storage
o Specifies the storage system to use.
o Defaults to :db_file. Options are :file_system, :db_file, and :s3.

* :processor
o Sets the image processor to use for resizing of the attached image.
o Options include ImageScience, Rmagick, and MiniMagick. Default is whatever is installed.

* :content_type
o Allowed content types.
o Allows all by default. Use :image to allow all standard image types.

* :min_size
o Minimum size allowed.
o 1 byte is the default.

* :max_size
o Maximum size allowed.
o 1.megabyte is the default.



Reference link is: http://www.jumbabox.com/2008/06/attachment_fu-tutorial/

Thursday, November 20, 2008

Color Combinations

#669851 #950303 #FAFF02 #2E4F00
#3D5E31 #600202 #C4BF23 #78D700
#58679E #DEBB01 #140FDB #CE5401
#C9B68C #DEBB01 #08047D #813100
#975264 #232A3D #B13B00 #080F19
#6C3D47 #5D8DBD #FF5605 #314D7D
#252A3D #394F67

For more details visit
http://www.allwebdesignresources.com/colorschemescombinations.html

Friday, October 17, 2008

Solution For "rewrite" error

If you get this error, and the error message is pointing you to a “link_to” call or something similar, then you may be using an instance variable that’s called ‘@url’ too.

I finally discovered that, in my case, I was using ‘@url’ in the controller for the view where I was making the ‘link_to’ call.

Long story short, if you see this error, comb through your code (models, controllers and views) for any variables that are called ‘@url’ and change them.


Reason:

We should not use "url" word as controller name,model name,action name,attribute name ..
Apparently you can’t use “Class” as a class in Java either.

Yep, same as ‘private’, ‘public’, etc. With the slight difference that these are keywords at the language as oposed to framework level.


Solution:
Then simply replace url word with other..

Sunday, September 21, 2008

RSS

what is RSS
RSS is a format for syndicating news and the content of news-like sites, including major news sites like Wired, news-oriented community sites like Slashdot, and personal weblogs. But it's not just for news. Pretty much anything that can be broken down into discrete items can be syndicated via RSS: the "recent changes" page of a wiki, a changelog of CVS checkins, even the revision history of a book. Once information about each item is in RSS format, an RSS-aware program can check the feed for changes and react to the changes in an appropriate way.

precisely in points

-> Really Simple Syndication.

->It is a easy way to share defined content and news/titles/posts from www

->RSS is written in XML

uses of RSS

RSS started out with the intent of distributing news related headlines. The potential for RSS is significantly larger. Consider using RSS for the following:

New Homes - realtors can provide updated feeds of new home listings on the market

Job Openings - placement firms and newspapers can provide a classifieds feed of job vacancies

Auction Items - auction vendors can provide feeds containing items that have been recently added to ebay or other auction sites

Forum Headlines - support forums can provide a listing of new forum threads

Product Sales or Specials - one look at Amazon opens the mind to the endless product sale potential using RSS. Currently Amazon delivering a headline-view of the top 10 bestsellers in that category or set of search results.

Airlines - report flight delays

Schools - schools can relay homework assignments and quickly announce school cancellations.

Entertainment - listings of the latest tv programs or movies at local theatres

Press Distribution - feed for press with new releases

News & Announcements - headlines, notices and any list of announcements

Document listings - lists of added or changed pages, so that people don't need to constantly check for updates

Bookmarks and other external links - perfect for sharing lists of external links

Calendars - listings of past or upcoming events, deadlines or holidays

Law Enforcement - let the community know of location and status of sex offenders as they move into a community.

Search results - to let people track changing or new results to their searches

RSS in the Government - Site details how RSS is used by various government agencies

How to use RSS

Ruby excellently supports the RSS implementations. RSS (v0.9, v1.0, v2.0), maker and parser. Moving ahead here I will be showing few examples how do we parse/generate the RSS feeds in Rails application.

Note: An RSS document is often referred as “feed” or "channel"
Posted by shaik abdul hafeez at 3:01 AM 0 comments
Maker:
Maker creates/generates the feed/RSS document of a site/blog. Since there are multiple versions of the RSS available based on the version we need to include/require those libraries while making the feed.


# A controller that would handle all the feed related actions, includes/refers the required libraries.
# An action/method that would use the rss/maker library to read the feed.
# Extract the necessary elements/content.
# Pass on the elements/content to the views (RHTML/RXML).

# making feed for Top urls feeds



def generate_feed
version = "2.0" # ["0.9", "1.0", "2.0"]
destination = "destination file" # local file to write
content = RSS::Maker.make(version) do |m|
m.channel.title = "tilte of RSS feeds"
m.channel.link = "http://rubyforge.org"
m.channel.description = "These are my Top url clips"
m.channel.webMaster ="webmaster@rubyforge.org"
m.channel.date = Time.now

i = m.items.new_item
i.title = "give title here"
i.link = "give link here"
i.description = "write description here"
i.date = Time.now
end
# content = @response
File.open(destination,"w") do |f|
f.write(content)
end
end

Parser:

Parser identifies the feed Url provided and reads the document and we can publish the feed with our own display options. So all that we need is a simple feed url. Let us say we need to publish the feed content of particular site on our blog/site.

Since there are multiple versions of the RSS available based on the version we need to include/require those libraries while parsing the feed.

# A controller that would handle all the feed related actions, includes/refers the required libraries.
# An action/method that would use the rss/parser library to read the feed.
# Extract the necessary elements/content.
# Pass on the elements/content to the views.


class RssFeedController <>

#This action is used to get the rss feed of the blog mentioned

def parse_feed

source = "here source file" # url or local file
content = "" # raw content of rss feed will be loaded here
open(source) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)
@rss=rss
render :layout => false
end
end

Saturday, August 9, 2008

Top Ten Mistakes in Web Design

Summary:
The ten most egregious offenses against users. Web design disasters and HTML horrors are legion, though many usability atrocities are less common than they used to be.


1. Bad Search
Overly literal search engines reduce usability in that they're unable to handle typos, plurals, hyphens, and other variants of the query terms. Such search engines are particularly difficult for elderly users, but they hurt everybody.

A related problem is when search engines prioritize results purely on the basis of how many query terms they contain, rather than on each document's importance. Much better if your search engine calls out "best bets" at the top of the list -- especially for important queries, such as the names of your products.

Search is the user's lifeline when navigation fails. Even though advanced search can sometimes help, simple search usually works best, and search should be presented as a simple box, since that's what users are looking for.
2. PDF Files for Online Reading
Users hate coming across a PDF file while browsing, because it breaks their flow. Even simple things like printing or saving documents are difficult because standard browser commands don't work. Layouts are often optimized for a sheet of paper, which rarely matches the size of the user's browser window. Bye-bye smooth scrolling. Hello tiny fonts.

Worst of all, PDF is an undifferentiated blob of content that's hard to navigate.

PDF is great for printing and for distributing manuals and other big documents that need to be printed. Reserve it for this purpose and convert any information that needs to be browsed or read on the screen into real web pages.

> Detailed discussion of why PDF is bad for online reading
3. Not Changing the Color of Visited Links
A good grasp of past navigation helps you understand your current location, since it's the culmination of your journey. Knowing your past and present locations in turn makes it easier to decide where to go next. Links are a key factor in this navigation process. Users can exclude links that proved fruitless in their earlier visits. Conversely, they might revisit links they found helpful in the past.

Most important, knowing which pages they've already visited frees users from unintentionally revisiting the same pages over and over again.

These benefits only accrue under one important assumption: that users can tell the difference between visited and unvisited links because the site shows them in different colors. When visited links don't change color, users exhibit more navigational disorientation in usability testing and unintentionally revisit the same pages repeatedly.

> Usability implications of changing link colors
> Guidelines for showing links Cartoon - guy being crushed under wordy 'terms and conditions' legalese
4. Non-Scannable Text


A wall of text is deadly for an interactive experience. Intimidating. Boring. Painful to read.

Write for online, not print. To draw users into the text and support scannability, use well-documented tricks:

* subheads
* bulleted lists
* highlighted keywords
* short paragraphs
* the inverted pyramid
* a simple writing style, and
* de-fluffed language devoid of marketese.

> Eyetracking of reading patterns
5. Fixed Font Size
CSS style sheets unfortunately give websites the power to disable a Web browser's "change font size" button and specify a fixed font size. About 95% of the time, this fixed size is tiny, reducing readability significantly for most people over the age of 40.

Respect the user's preferences and let them resize text as needed. Also, specify font sizes in relative terms -- not as an absolute number of pixels.
6. Page Titles With Low Search Engine Visibility
Search is the most important way users discover websites. Search is also one of the most important ways users find their way around individual websites. The humble page title is your main tool to attract new visitors from search listings and to help your existing users to locate the specific pages that they need.

The page title is contained within the HTML microcontent.

Page titles are also used as the default entry in the Favorites when users bookmark a site. For your homepage, begin the with the company name, followed by a brief description of the site. Don't start with words like "The" or "Welcome to" unless you want to be alphabetized under "T" or "W."

For other pages than the homepage, start the title with a few of the most salient information-carrying words that describe the specifics of what users will find on that page. Since the page title is used as the window title in the browser, it's also used as the label for that window in the taskbar under Windows, meaning that advanced users will move between multiple windows under the guidance of the first one or two words of each page title. If all your page titles start with the same words, you have severely reduced usability for your multi-windowing users.

Taglines on homepages are a related subject: they also need to be short and quickly communicate the purpose of the site.
7. Anything That Looks Like an Advertisement
Selective attention is very powerful, and Web users have learned to stop paying attention to any ads that get in the way of their goal-driven navigation. (The main exception being text-only search-engine ads.)

Unfortunately, users also ignore legitimate design elements that look like prevalent forms of advertising. After all, when you ignore something, you don't study it in detail to find out what it is.

Therefore, it is best to avoid any designs that look like advertisements. The exact implications of this guideline will vary with new forms of ads; currently follow these rules:

* banner blindness means that users never fixate their eyes on anything that looks like a banner ad due to shape or position on the page
* animation avoidance makes users ignore areas with blinking or flashing text or other aggressive animations
* pop-up purges mean that users close pop-up windoids before they have even fully rendered; sometimes with great viciousness (a sort of getting-back-at-GeoCities triumph).

8. Violating Design Conventions
Consistency is one of the most powerful usability principles: when things always behave the same, users don't have to worry about what will happen. Instead, they know what will happen based on earlier experience. Every time you release an apple over Sir Isaac Newton, it will drop on his head. That's good.

The more users' expectations prove right, the more they will feel in control of the system and the more they will like it. And the more the system breaks users' expectations, the more they will feel insecure. Oops, maybe if I let go of this apple, it will turn into a tomato and jump a mile into the sky.

Jakob's Law of the Web User Experience states that "users spend most of their time on other websites."

This means that they form their expectations for your site based on what's commonly done on most other sites. If you deviate, your site will be harder to use and users will leave.
9. Opening New Browser Windows
Opening up new browser windows is like a vacuum cleaner sales person who starts a visit by emptying an ash tray on the customer's carpet. Don't pollute my screen with any more windows, thanks (particularly since current operating systems have miserable window management).

Designers open new browser windows on the theory that it keeps users on their site. But even disregarding the user-hostile message implied in taking over the user's machine, the strategy is self-defeating since it disables the Back button which is the normal way users return to previous sites. Users often don't notice that a new window has opened, especially if they are using a small monitor where the windows are maximized to fill up the screen. So a user who tries to return to the origin will be confused by a grayed out Back button.

Links that don't behave as expected undermine users' understanding of their own system. A link should be a simple hypertext reference that replaces the current page with new content. Users hate unwarranted pop-up windows. When they want the destination to appear in a new page, they can use their browser's "open in new window" command -- assuming, of course, that the link is not a piece of code that interferes with the browser’s standard behavior. Cartoon - woman (at car dealership): 'How much is it with automatic transmission?' - sleazy salesman: 'I'll give you a hint - it's an EVEN number...'
10. Not Answering Users' Questions
Users are highly goal-driven on the Web. They visit sites because there's something they want to accomplish -- maybe even buy your product. The ultimate failure of a website is to fail to provide the information users are looking for.

Sometimes the answer is simply not there and you lose the sale because users have to assume that your product or service doesn't meet their needs if you don't tell them the specifics. Other times the specifics are buried under a thick layer of marketese and bland slogans. Since users don't have time to read everything, such hidden info might almost as well not be there.

The worst example of not answering users' questions is to avoid listing the price of products and services. No B2C ecommerce site would make this mistake, but it's rife in B2B, where most "enterprise solutions" are presented so that you can't tell whether they are suited for 100 people or 100,000 people. Price is the most specific piece of info customers use to understand the nature of an offering, and not providing it makes people feel lost and reduces their understanding of a product line. We have miles of videotape of users asking "Where's the price?" while tearing their hair out.

Even B2C sites often make the associated mistake of forgetting prices in product lists, such as category pages or search results. Knowing the price is key in both situations; it lets users differentiate among products and click through to the most relevant ones.

Source : http://www.useit.com/alertbox/9605.html

Wednesday, July 9, 2008

yeah your guess is right just i started my career with ruby on rails.
In the month of November, i started my journey.

i will post my experiences soon