added documentation about :plist_filename
This commit is contained in:
parent
30931f0384
commit
7a3c754e6b
2 changed files with 13 additions and 4 deletions
11
README
11
README
|
@ -2,7 +2,8 @@ Plistifier
|
|||
==========
|
||||
|
||||
Adds the ActiveRecord#to_plist and Array#to_plist methods similar to ActiveRecord#to_xml.
|
||||
The :only, :except, :methods, and :include options are supported.
|
||||
The :only, :except, :methods, and :include options are supported. Additionally you can use
|
||||
the :plist_filename option to change the default name for download.
|
||||
|
||||
It too ads the :plist option to the ActiveRecord::Base#render method. With help of that
|
||||
you get binary plist files which you can easy use in your iPhone.
|
||||
|
@ -39,6 +40,14 @@ In your PostController use for example:
|
|||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@post = Post.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.plist { render :plist => @post, :plist_filename => "a-testfile.plist" }
|
||||
end
|
||||
end
|
||||
|
||||
On the iPhone use for example:
|
||||
|
||||
NSURL *url = [NSURL URLWithString:@"http://example.com/posts.plist"];
|
||||
|
|
|
@ -30,9 +30,9 @@ module ActionController
|
|||
|
||||
unless options.nil? or options[:plist_filename].blank?
|
||||
if plist.is_a? Array
|
||||
filename = plist.first.class.name.pluralize
|
||||
filename = plist.first.class.name.pluralize + ".plist"
|
||||
else
|
||||
filename = "#{plist.class.name}-#{plist.id}"
|
||||
filename = "#{plist.class.name}-#{plist.id}.plist"
|
||||
end
|
||||
else
|
||||
filename = options[:plist_filename]
|
||||
|
@ -41,7 +41,7 @@ module ActionController
|
|||
send_data(
|
||||
plist.to_plist(options),
|
||||
:type => Mime::PLIST,
|
||||
:filename => "#{filename}.plist",
|
||||
:filename => filename,
|
||||
:disposition => 'inline'
|
||||
)
|
||||
|
||||
|
|
Reference in a new issue