关闭

rails实现功能示例

742人阅读 评论(0) 收藏 举报
1.download file
 
 view :  <%= link_to 'Get Readme', :action => 'get_readme' %>Finally, add the "get_readme" action method to your controller:
controller: 
  def get_readme
     send_file("files/README.txt", :filename => 'yo_readme.txt')
  end
2.reload page with out refresh
view1: <%= link_to_remote ( 'test',:update => 'live-preview',
                                :url => { :action => 'showDiv', :id => restaurant.id },
                                :complete => visual_effect(:highlight, 'live-preview', :duration => 1)) %>
         <div id="live-preview" style="position:absolute;top:100;left:100; 
             Z-index:1;border: 1px solid">
view2(showDiv.rhtml):
<p>
<% if (@restaurant != nil )%>
    <
%=@restaurant.id%>
    <br>
    <
%=@restaurant.content1%>
    <br>
    <
%=@restaurant.content2%>
    <br>
    <
%=@restaurant.content2%>
<% end%>
</p>
controller :   
    def showDiv
    @restaurant = Restaurant.find(params[:id])
  end
'live-preview' is id of my html element
'showDiv' is my defined controller
restaurant.id is the data send to controller
visual_effect is the inline effect function 
3. X.methods
display all the Methods of  'X' Object
like  String.methods
["mattr_reader", "included_modules", "write_inheritable_hash",
 "instance_variable_get", "autoload", "const_missing", 
"class_inheritable_array", "b64encode", "silence_stream", 
"to_s", "public_instance_methods", "remove_class", "cattr_writer", 
"to_json", "respond_to?", "clone", "mattr_writer", "nil?", "reset_inheritable_attributes", 
"require_gem_with_options", "to_yaml_style", "instance_variable_set", 
"class_inheritable_option", "class_variables", "yaml_tag_read_class",
 "new", "class_inheritable_hash", "__send__", "inspect",
 "protected_instance_methods", "include?", "cattr_accessor", "dup", "autoload?", "equal?", 
"method_defined?", "name", "mattr_accessor", "extend_with_included_modules_from", 
"taguri", "instance_method", "inheritable_attributes", "methods", "taguri=", "yaml_as",
 "private_instance_methods", "parent", "send", "rails_original_const_missing", "taint", 
"delegate", "yaml_tag_subclasses?", "eql?", "public_method_defined?", "ancestors", 
"instance_values", "display", "hash", "singleton_methods", "suppress", "constants", "`", 
"instance_eval", "class_inheritable_reader", "instance_of?", "to_yaml", "blank?", "daemonize", 
"private_method_defined?", "instance_exec", "id", "write_inheritable_attribute", "encode64", 
"protected_methods", "yaml_tag_class_name", "tainted?", "const_get", 
"class_inheritable_writer", "to_yaml_properties", "kind_of?", "silence_warnings", "untaint", 
"parents", "protected_method_defined?", "remove_subclasses", "yaml_new", "__id__", 
"public_class_method", "superclass", "write_inheritable_array", "included_in_classes", 
"private_methods", "extended_by", "method_added", "const_set", 
"class_inheritable_array_writer", "decode_b", "freeze", "extend",
 "is_a?", "dclone", "remove_subclasses_of", "returning", "object_id", 
"private_class_method", "require_gem", "<=>", "load", "==", "public_methods", 
"copy_instance_variables_from", "decode64", "===", "class_inheritable_hash_writer", 
">=", "enable_warnings", "subclasses", "<=", "include_all_modules_from", "as_load_path",
 "cattr_reader", "with_options", "type", "module_eval", "=~", "const_defined?", 
"read_inheritable_attribute", "instance_variables", "<", "require_library_or_gem", 
"require", "frozen?", "method", ">", "class_inheritable_accessor", "silence_stderr", 
"to_a", "allocate", "instance_methods", "subclasses_of", "class", "class_eval"]
 
 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1655831次
    • 积分:20093
    • 等级:
    • 排名:第422名
    • 原创:91篇
    • 转载:1131篇
    • 译文:0篇
    • 评论:145条
    文章分类
    最新评论