学习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 感兴趣, ...
随机推荐
- (zxing.net)二维码PDF417的简介、实现与解码
一.简介 二维码PDF417是一种堆叠式二维条码.PDF417条码是由美国SYMBOL公司发明的,PDF(Portable Data File)意思是“便携数据文件”.组成条码的每一个条码字符由4个条 ...
- C# SQLite 数据库
数据库 Oracle.Oracle的应用,主要在传统行业的数据化业务中,比如:银行.金融这样的对可用性.健壮性.安全性.实时性要求极高的业务 MS SQL Server.windows生态系统的产品, ...
- Rx.net 例子——(1)基础
1.订阅序列 using System; using System.Collections.Generic; using System.Linq; using System.Text; using S ...
- windows 10 自适应布局
https://msdn.microsoft.com/library/windows/apps/dn894631.aspx Use visual state triggers to build UI ...
- iOS Apple Watch 开发
1. Watch OS 1 与 Watch OS 2 的区别 : OS 1 中界面运行在手表上,而代码(Extension)运行在手机端:OS 2 是纯正的手表原生(Native)应用 由于架构的改变 ...
- JSOI2008 Blue Mary开公司 | 李超线段树学习笔记
题目链接:戳我 这相当于是一个李超线段树的模板qwqwq,题解就不多说了. 代码如下: #include<iostream> #include<cstdio> #include ...
- RabbitMq初探——发布与订阅
publish and subscribe 前言 前面的例子 我们都是用到的都是消息单一消费,即一条消息被单个消费者消费.像微博系统的消息推送,是一条消息推送给所有订阅到该频道的用户. 这里我们就需要 ...
- leetcode 72 编辑距离 JAVA
题目: 给定两个单词 word1 和 word2,计算出将 word1 转换成 word2 所使用的最少操作数 . 你可以对一个单词进行如下三种操作: 插入一个字符 删除一个字符 替换一个字符 示例 ...
- Python3.5 学习三
对文件的操作 打开模式: 1 f=open("xxx","r",encoding=="utf-8") 只读 2 f=open("x ...
- [转载] cassandra Unable to complete request: one or more nodes were unavailable
今天碰到的问题跟这个一模一样,特地转过来记录一下 https://support.datastax.com/hc/en-us/articles/204893189-CQL-query-results- ...