Giter Club home page Giter Club logo

dry_view's Introduction

Example:
  说明:
  将常用的View公用, 统一了I18n 

  # Controller
  class BlogController < InheritedResources::Base
		dry_view :columns => [:title, :body]
  end

	# Model
  class Blog
	  def label
		  self.title
		end
  end

# 依赖
  此功能依赖 inherited_resources( http://github.com/josevalim/inherited_resources/tree/master )
	可以用以下命令安装
	script/plugin install git://github.com/josevalim/inherited_resources.git

	其中 form 的布局和 Css 来自 formtastic (http://github.com/justinfrench/formtastic/tree/master)

# Useage
  1  ./script/plugin install git://github.com/alvin2ye/dry_view.git
	2  ./script/plugin install git://github.com/josevalim/inherited_resources.git
	3  ./script/generate Model Company name:string addr:string
	4  rake db:migrate
	5  ruby script/generate controller companies
	6  
		 # app/controllers/companies_controller.rb
		 class CompaniesController < InheritedResources::Base
		 	dry_view
		 end

		 #  app/models/company.rb
		 class Company < ActiveRecord::Base
		   def label
		 		self.name
		 	end
		 end

		 # config/routes.rb
		 map.resources :companies

	7	 rake dry_view:install
	8  add to layout: <%= stylesheet_link_tag "formtastic" %>

# I18n
  # config/locales/zh.yml
	zh:
		dry_view:
			actions: "操作"
			view: "查看"
			edit: "编辑"
			remove: "删除"
			new: "新建"
			submit: "提交"
			required: "必填"
			cancel: "取消"
			return_index: "返回列表"
			are_you_sure: "你确认吗?" 

# Config
     
		 class CompaniesController < InheritedResources::Base
		   # Only display this columns, default is all columns except [:id, :created_at, :updated_at]
			 dry_view :columns => [:name, :code]
		 end

Copyright (c) 2009 Alvin Ye at Agideo, released under the MIT license   
alvin.ye.cn(*)gmail.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.