| View previous topic :: View next topic |
| Author |
Message |
ktulasi
Joined: 21 Oct 2009 Posts: 59
|
Posted: Thu Jan 21, 2010 2:01 pm Post subject: Mime type in rails |
|
|
hello friends,
Can any one tell me what is the Mime type in rails.
Thanks in advance. |
|
| Back to top |
|
 |
swaminadhan
Joined: 14 Sep 2009 Posts: 84
|
Posted: Thu Jan 21, 2010 2:13 pm Post subject: |
|
|
Hi,
Mime types will helps in rendering the content in many ways, that means displaying the content on many ways which is visible to the user.
Normally we have to add the file extensions o the mime type but in general few mime types were included in the default library.
WE can compile the mime types and we should place in th lib folder
You only need to add mime types to Rails if you intend to generate responses for them
Mime::Type will fail on extensions starting with a number (like .3gp) because it tries to define a constant for every extension, and of course constants can’t start with a number.
Some great Rails plugins like attachment_fu use the content type/mime type of a file to validate the instance of an object
When we use this attachment_fu plugin we will use the content type and we will give the image extensions as .jpj or .png.
Mime::Type.register will add the image/png mime type to the collection of mime types, bind it to the .png extension. It also creates a special Mime::Type instance at Mime::PNG
Thank you,
swaminadhan. |
|
| Back to top |
|
 |
suryakantb
Joined: 02 Dec 2009 Posts: 1 Location: India
|
Posted: Fri Jan 22, 2010 12:34 pm Post subject: |
|
|
Hi,
Check this out
Encapsulates the notion of a mime type. Can be used at render time, for example, with:
class PostsController < ActionController::Base
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html
format.ics { render :text => post.to_ics, :mime_type => Mime::Type["text/calendar"] }
format.xml { render :xml => @people.to_xml }
end
end
end |
|
| Back to top |
|
 |
|