学习Rails之activeAdmin
同时,这个时候会显示相关的配置信息,并按照配置信息完成相关指示操作。
Some setup you must do manually if you haven't yet:
1. Ensure you have defined default url options
in your environments files. Here
is an example of default_url_options appropriate for a development
environment
in config/environments/development.rb:
config.action_mailer.default_url_options = { :host
=> 'localhost:3000' }
In production, :host should be set to the actual host of your
application.
2. Ensure you have defined root_url to
*something* in your config/routes.rb.
For example:
root :to => "home#index"
3. Ensure you have flash messages in
app/views/layouts/application.html.erb.
For example:
<p class="notice"><%=
notice %></p>
<p class="alert"><%=
alert %></p>
4. If you are deploying Rails 3.1+ on Heroku,
you may want to set:
config.assets.initialize_on_precompile = false
On config/application.rb forcing your application to not access the
DB
or load models when precompiling your assets.
5. You can copy Devise views (for customization)
to your app by running:
rails g devise:views
编辑config/initializers/devise.rb
#
Configure the e-mail address which will be shown in
DeviseMailer. config.mailer_sender
="xxx@126.com" #换成你的邮箱,最好不要是gmail编辑config/environments/development.rb
# Don't care if the mailer
can't send
config.action_mailer.raise_delivery_errors
=true #此处改为true config.action_mailer.default_url_options
= {:host =>"localhost:3000" }#刚才devise的提示中提到这一句 config.action_mailer.delivery_method
=:smtp config.action_mailer.smtp_settings
= { :address=>"smtp.126.com", :port=>25, :domain=>"126.com", :authentication=>:login, :user_name=>"xxx@126.com",#你的邮箱 :password=>"xxxxxx" #你的密码 }5、迁移你的db ,rake
db:migrate,然后运行rails server 。
model [MyModelName] name:string
title:string content:text
generate active_admin:resource [MyModelName]
'activeadmin','0.5.1'
'arbre','1.0.1'
'bourbon','1.0.0'
'devise','1.5.4'
'formtastic','2.1.0'
'has_scope','0.5.1'
'inherited_resources','1.3.1'
'meta_search','1.1.3'
'orm_adapter','0.0.3'
'polyamorous','0.5.0'
'responders','0.6.5'
'warden','1.1.1'
do
do
,:label=>"标题"
,:label=>"作者"
,:label=>"内容"
do
f.input :title,:label=>"标题"
f.input :name,:label=>"作者"
f.input :content,:label=>"文章内容"
:index do
"如果你对网站后台管理有问题,请联系CreateByRails@yeah.net"
1、现在将整个页面汉化一下
首先,我们已经在config/application.rb里配置了local为
zh-CN,
# The
default locale is :en and all translations from
config/locales/*.rb,yml are auto loaded.
config.i18n.load_path += Dir[Rails.root.join('config', 'locales',
'*.{rb,yml}').to_s]
config.i18n.default_locale = "zh-CN"
然后到http://github.com/tsechingho/rails-i18n/blob/master/rails/locale/zh-CN.yml
下载已经配置好的中文包到config/locales里,这样,rails的中文化已经做好了。
2、devise的汉化
到该Wiki去下载汉化包
devise.zh-CN.yml
https://github.com/plataformatec/devise/wiki/I18n
然后删除原来的devise.en.yml
3、解决编码问题
在你需要显示汉语的*.rb文件中 ,添加一句代码
#encoding:utf-8
学习Rails之activeAdmin的更多相关文章
- Rails中activeAdmin的使用
一.开始ActiveAdmin Active Admin是一个发布在RAILS3中使用的Gem. 1.我们为了快速开始我们对Active Admin的了解,我们首先安装它: 在你GemFile中添加g ...
- 开始了大概三四天的Rails学习之路
最近因为一位极光推送朋友,我开始了大概三四天的Rails学习之路,最终达到的水平是可以比较轻松地做出大部分功能,然后自我感觉可以自如地按照Rails的设计思想去思考.由于编程的日益流行,我结识了越来越 ...
- [Rails学习之路]初识Ruby(一)
Ruby是一门动态的.强类型的.纯面向对象的编程语言.它和Python非常相似,但比Python面向对象更加彻底.使用更加灵活.语法更加复杂.也更为有趣. 抛开做事情到底应该有多少种方法这个问题,我相 ...
- Rails中的缓存
最近学习Rails. 看到如下代码: <% if notice %> <p id="notice"><%= notice %></p> ...
- Ruby学习资源汇总
from:http://segmentfault.com/a/1190000000362058 Ruby 语言 Try Ruby: 无需在你的系统中安装.Ruby,只要通过浏览器便可立即体验 Ruby ...
- 【转】如何从零开始学会 Ruby on Rails?
文章转自:http://huacnlee.com/blog/how-to-start-learning-ruby-on-rails/ 这个话题曾经给身边的很多朋友说过同样的话题,这里整理以下. 如果你 ...
- 如何从 0 开始学 ruby on rails (漫步版)
如何从 0 开始学 ruby on rails (漫步版) ruby 是一门编程语言,ruby on rails 是 ruby 的一个 web 框架,简称 rails. 有很多人对 rails 感兴 ...
- 有意练习--Rails RESTful(一)
书要反复提及<哪里有天才>在说,大多数所谓的天才是通过反复刻意练习获得. 当你的练习时间达到10000几个小时后,.你将成为该领域的专家. 近期在学习rails怎样实现RESTful We ...
- 如何从 0 开始学 Ruby on Rails
如何从 0 开始学 Ruby on Rails (漫步版)Ruby 是一门编程语言,Ruby on Rails 是 Ruby 的一个 web 框架,简称 Rails. 有很多人对 Rails 感兴趣, ...
随机推荐
- 基于pscp批量分发文件
用法: pscp -h 目标ip文件 本地文件路径 远程路径 pscp -h hosts.ip file.txt ~/
- asp.net mvc5 下载文件方法
控制器自带的 FileContentResult 可以让我们很方便的返回文件到服务端,减少了很多步骤.用于下载文件的时候,像视频.文本.图片这种浏览器支持的文件,默认就会被浏览器打开.这时候想让它变成 ...
- 使用Hbuilder将自己app发布到App Store(一)
1.如果你有mac系统那请看第二步. 首先需要一台虚拟机,还需要个插件要不没法装,都在这链接里面了 链接:https://pan.baidu.com/s/1N_pWJWFk-EJILTXuFr6w5g ...
- java随笔——HashMap与红黑树
前言: hashmap是一种很常用的数据结构,其使用方便快捷,接下来笔者将给大家深入解析这个数据结构,让大家能在用的时候知其然,也知其所以然. 一.Map 首先,从最基本的讲起,我们先来认识一下map ...
- django drf Token验证
https://www.django-rest-framework.org/api-guide/authentication/#basicauthentication 1.INSTALLED_APPS ...
- 安装OWA2013
首先可以参考以下博客进行安装 http://www.cnblogs.com/poissonnotes/p/3238238.html 需要特别注意的是,我的SHAREPOINT系统虽然是英文版的,但是同 ...
- git删除未监视的文件
新增的文件使用git status查看会提示Untracked files,如果想要删除Untracked files,可以使用如下命令: git clean -f # 删除Untracked fil ...
- java -io字符流FileWrite操作演示
FileWriter字符输出流演示: /* * FiileWriter 字符流的操作 * FileWriter 的构造方法 可传递 File类型 还可以传递String类型 * * 方法 : * wr ...
- 小A的旅行(绿豆蛙的归宿)【期望DP】
Description 给出一个有向无环的连通图,起点为1,终点为N,每条边都有一个长度.小A从起点出发,走向终点.到达每一个顶点时,如果有K条离开该点的道路,小A可以选择任意一条道路离开该点,并且走 ...
- php请求远程url内容方法
php请求远程url内容有两个方法fopen/file_get_contents和curl. 1,fopen/file_get_contents与curl的差异 (1)fopen /file_get_ ...