1、一个完整的rails app自动生成bash
3、bash设置
4、
引用
#!/bin/bash
clear
echo -e "Preparing to start ...\n"
cd /Users/gelias/workspace/ruby
echo -e "removing oldest version ... \n"
rm -rf /Users/gelias/workspace/ruby/cardapiaria
echo -e "using ruby version 1.9.3 and Rails 3.2"
rvm 1.9.3@rails32
echo -e "generating cardapiaria app"
rails new cardapiaria --database postgresql
cd cardapiaria
rails generate scaffold Establishment name:string description:string address:string phone:integer url:string
rails generate scaffold User establishment_id:integer login:string passwd:string email:string
rails generate scaffold Category establishment_id:integer description:string
rails generate scaffold MenuItem category_id:integer name:string description:string price:decimal
echo -e "\nEdit menu_item migration file and replace the following line ..."
echo -e " t.decimal :price"
echo -e "to ..."
echo -e " t.decimal :price, :precision => 10, :scale => 2"
read -p "press any key to continue ... "
echo -e "generating migration and relationships"
rails generate migration AddEstablishmentIdToUser establishment_id:integer
rails generate migration AddEstablishmentIdToCategory establishment_id:integer
rails generate migration AddCategoryIdToMenuItem category_id:integer
echo -e "\noverriding models ... "
rm -rf /Users/gelias/workspace/ruby/cardapiaria/config/database.yml
cp -rf /Users/gelias/workspace/ruby/cardapiaria_setup/database.yml /Users/gelias/workspace/ruby/cardapiaria/config/database.yml
cp -rf /Users/gelias/workspace/ruby/cardapiaria_setup/models /Users/gelias/workspace/ruby/cardapiaria/app
read -p "press any key to continue ... "
echo -e "\running migrations"
rake db:migrate
echo -e "\starting weBrick ..."
rails server
clear
echo -e "Preparing to start ...\n"
cd /Users/gelias/workspace/ruby
echo -e "removing oldest version ... \n"
rm -rf /Users/gelias/workspace/ruby/cardapiaria
echo -e "using ruby version 1.9.3 and Rails 3.2"
rvm 1.9.3@rails32
echo -e "generating cardapiaria app"
rails new cardapiaria --database postgresql
cd cardapiaria
rails generate scaffold Establishment name:string description:string address:string phone:integer url:string
rails generate scaffold User establishment_id:integer login:string passwd:string email:string
rails generate scaffold Category establishment_id:integer description:string
rails generate scaffold MenuItem category_id:integer name:string description:string price:decimal
echo -e "\nEdit menu_item migration file and replace the following line ..."
echo -e " t.decimal :price"
echo -e "to ..."
echo -e " t.decimal :price, :precision => 10, :scale => 2"
read -p "press any key to continue ... "
echo -e "generating migration and relationships"
rails generate migration AddEstablishmentIdToUser establishment_id:integer
rails generate migration AddEstablishmentIdToCategory establishment_id:integer
rails generate migration AddCategoryIdToMenuItem category_id:integer
echo -e "\noverriding models ... "
rm -rf /Users/gelias/workspace/ruby/cardapiaria/config/database.yml
cp -rf /Users/gelias/workspace/ruby/cardapiaria_setup/database.yml /Users/gelias/workspace/ruby/cardapiaria/config/database.yml
cp -rf /Users/gelias/workspace/ruby/cardapiaria_setup/models /Users/gelias/workspace/ruby/cardapiaria/app
read -p "press any key to continue ... "
echo -e "\running migrations"
rake db:migrate
echo -e "\starting weBrick ..."
rails server
引用
2、第二个bash
rbenv-install.sh
Shell
#!/bin/bash
#=====================================
# Settings Here
#=====================================
# Platform
PLATFORM=Ubuntu
#PLATFORM="CentOS"
# Rails Application Name
RAILS_APP_NAME=example
# Ruby Version
#RUBY_VERSION=2.0.0-p247
RUBY_VERSION=1.9.3-p392
# Rails Version
#RAILS_VERSION=4.0.0
RAILS_VERSION=3.2.14
# Git User Configuration
GIT_USER_NAME="Wataru Noguchi"
EMAIL="user@example.com"
GIT_OPTIONS=--global
#=====================================
if [ "$PLATFORM" = "Ubuntu" ]; then
sudo apt-get -y install libssl-dev zlib1g-dev libreadline-dev libmysqlclient-dev sqlite3 libsqlite3-dev g++ git curl
else
yum -y groupinstall "Development Tools"
yum -y install openssl-devel zlib-devel readline-devel mysql-devel sqlite-devel git
fi
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
cd ~/.rbenv/plugins/ruby-build/
sudo ./install.sh
rbenv install $RUBY_VERSION
rbenv global $RUBY_VERSION
rbenv rehash
rbenv exec gem install bundler --no-ri --no-rdoc
rbenv rehash
cd ~
mkdir rails_projects
cd rails_projects/
cat << EOS > Gemfile
source "https://rubygems.org"
gem "rails", "$RAILS_VERSION"
EOS
bundle install --path vendor/bundle
bundle exec rails new $RAILS_APP_NAME --skip-bundle
cd $RAILS_APP_NAME
cat <<EOF >> Gemfile
gem 'execjs'
gem 'therubyracer'
EOF
bundle install --path vendor/bundle
echo '/vendor/bundle' >> .gitignore
git init
git add .
git config $GIT_OPTIONS user.name $USERNAME
git config $GIT_OPTIONS user.email $EMAIL
git commit -m "Initial commit."
echo "finished!"
rbenv-install.sh
Shell
#!/bin/bash
#=====================================
# Settings Here
#=====================================
# Platform
PLATFORM=Ubuntu
#PLATFORM="CentOS"
# Rails Application Name
RAILS_APP_NAME=example
# Ruby Version
#RUBY_VERSION=2.0.0-p247
RUBY_VERSION=1.9.3-p392
# Rails Version
#RAILS_VERSION=4.0.0
RAILS_VERSION=3.2.14
# Git User Configuration
GIT_USER_NAME="Wataru Noguchi"
EMAIL="user@example.com"
GIT_OPTIONS=--global
#=====================================
if [ "$PLATFORM" = "Ubuntu" ]; then
sudo apt-get -y install libssl-dev zlib1g-dev libreadline-dev libmysqlclient-dev sqlite3 libsqlite3-dev g++ git curl
else
yum -y groupinstall "Development Tools"
yum -y install openssl-devel zlib-devel readline-devel mysql-devel sqlite-devel git
fi
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
cd ~/.rbenv/plugins/ruby-build/
sudo ./install.sh
rbenv install $RUBY_VERSION
rbenv global $RUBY_VERSION
rbenv rehash
rbenv exec gem install bundler --no-ri --no-rdoc
rbenv rehash
cd ~
mkdir rails_projects
cd rails_projects/
cat << EOS > Gemfile
source "https://rubygems.org"
gem "rails", "$RAILS_VERSION"
EOS
bundle install --path vendor/bundle
bundle exec rails new $RAILS_APP_NAME --skip-bundle
cd $RAILS_APP_NAME
cat <<EOF >> Gemfile
gem 'execjs'
gem 'therubyracer'
EOF
bundle install --path vendor/bundle
echo '/vendor/bundle' >> .gitignore
git init
git add .
git config $GIT_OPTIONS user.name $USERNAME
git config $GIT_OPTIONS user.email $EMAIL
git commit -m "Initial commit."
echo "finished!"
3、bash设置
引用
.bashrc
PS1="mac osx:\W \$ "
alias gera="cd ~/Documents/railsapp/gera-it"
alias ra="cd ~/Documents/railsapp"
alias ss="cd ~/Documents/railsapp/sstore-experimental"
alias rs="rails s"
alias rc="rails c"
alias rg="rails g"
alias m="mate"
alias bu="bundle"
alias dbm="rake db:migrate"
PS1="mac osx:\W \$ "
alias gera="cd ~/Documents/railsapp/gera-it"
alias ra="cd ~/Documents/railsapp"
alias ss="cd ~/Documents/railsapp/sstore-experimental"
alias rs="rails s"
alias rc="rails c"
alias rg="rails g"
alias m="mate"
alias bu="bundle"
alias dbm="rake db:migrate"
4、
引用
newROR.sh
Shell
cd ~/rails/;
rails new {query};
#将capistrano代码复制过来
#capistrano代码请自行配置 http://railscasts.com/episodes/337-capistrano-recipes
cp -R ~/rails/ToolBox/capistrano/recipes ~/rails/{query}/config/;
cp ~/rails/ToolBox/capistrano/deploy.rb ~/rails/{query}/config/;
#在deploy.rb中设置应用名为APPLICATION_NAME
sed 's/APPLICATION_NAME/{query}/g' ~/rails/{query}/config/deploy.rb > ~/rails/{query}/config/deploy.rb;
#配置pow,如未使用可删除
cd ~/.pow;
ln -s ~/rails/{query};
cd ~/rails/{query}/;
#我使用bitbucket托管代码,用github自行修改
curl -u username:password -d "name={query}&scm=git&is_private=true&language=ruby" https://api.bitbucket.org/1.0/repositories
git init;
git remote add origin ssh://git@bitbucket.org/username/{query}.git;
git add .;
git commit -m "init project";
git push -u origin --all;
mate .;
Shell
cd ~/rails/;
rails new {query};
#将capistrano代码复制过来
#capistrano代码请自行配置 http://railscasts.com/episodes/337-capistrano-recipes
cp -R ~/rails/ToolBox/capistrano/recipes ~/rails/{query}/config/;
cp ~/rails/ToolBox/capistrano/deploy.rb ~/rails/{query}/config/;
#在deploy.rb中设置应用名为APPLICATION_NAME
sed 's/APPLICATION_NAME/{query}/g' ~/rails/{query}/config/deploy.rb > ~/rails/{query}/config/deploy.rb;
#配置pow,如未使用可删除
cd ~/.pow;
ln -s ~/rails/{query};
cd ~/rails/{query}/;
#我使用bitbucket托管代码,用github自行修改
curl -u username:password -d "name={query}&scm=git&is_private=true&language=ruby" https://api.bitbucket.org/1.0/repositories
git init;
git remote add origin ssh://git@bitbucket.org/username/{query}.git;
git add .;
git commit -m "init project";
git push -u origin --all;
mate .;
发表评论
-
rails 小技巧
2014-02-23 22:55 585#Rails Tip 1 Actions Are Method ... -
ruby 小技巧
2014-02-23 21:18 944#Track 1: The C in MVC #irb Mi ... -
rails 小代码合集 view controller model
2014-02-23 13:18 1609Rails Create an image with link ... -
实用工具--rails 命令、generator
2014-02-22 20:52 9931、rails 基本 rails new rails-boo ... -
rails 版本 更新/升级 release note
2014-02-22 14:02 566升级到 Rails 4,你的应用需要准备什么? 升 ... -
理解rails gems plugins
2014-02-22 13:06 648#33 Making a Plugin 引用注意 这种手法,可 ... -
日期 、路由辅助方法
2014-02-22 11:48 553#31 Formatting Time 方法一: Task ... -
rails 调试
2014-02-23 22:57 514#24 The Stack Trace A plugin c ... -
Authentication 用户登录 用户权限相关
2014-02-21 21:20 632引用 # 19Where Administration Goe ... -
ActiveRecord
2014-02-21 20:39 1028ActiveRecord 4新特性 http://www.os ... -
工作相关
2014-02-21 20:27 529# 工作经历: 2年制造业ERP开发及管理经验 2年旅游信息化 ... -
rails 开发工具相关
2014-02-21 20:14 470#使用TextMate进行Ruby On Rails开发推荐插 ... -
rails view session layout
2014-02-21 19:00 664#208 erb-blocks 简介:在erb中使用block ...
相关推荐
docker rails模板用于Rails应用程序或Rails + ... script/bootstrapdocker-compose exec rails bash 您可以在docker容器中执行任何命令。入门您可以从这样的模板构建Rails应用程序。 git clone https://github.c
code_quizzer, 使用 ruby JavaScript Rails 和Bash编程实践问题 CodeQuizzes关于站点在 ,Rails,JavaScript,Bash,git中包含一系列编程实践问题。 等等 !当我学习编程并决定创建CodeQuizzes作为我的第一个 Rails ...
Rails3 是 Ruby on Rails 框架的一个版本,它提供了一系列强大的命令行工具,使得开发者可以快速地构建和管理Web应用。在本文中,我们将深入探讨Rails3中的常用命令,帮助你更高效地进行开发工作。 首先,新建一个...
### CentOS环境下Rails 3开发环境搭建详解 #### 一、准备工作与环境配置 在开始部署Rails 3开发环境之前,我们需要确保系统上已经安装了一些基本的软件包和工具。这一步骤对于后续的Ruby和Rails安装至关重要。 ##...
Rails是Ruby on Rails框架的简称,它是一种基于Ruby语言的开源Web开发框架,以其MVC(Model-View-Controller)架构而闻名,旨在简化Web应用的开发过程。在早期的Rails版本中,Mongrel是一个常用的HTTP服务器,用于...
**Ruby-GoOnRails:利用Rails生成器构建Golang应用** Ruby on Rails(简称Rails)是一种流行的Web开发框架,以其“约定优于配置”的理念和高效的开发速度受到开发者喜爱。而Go(Golang)则是一种静态类型、编译型的...
### Mac上Rails环境的搭建详解 #### 一、前言 在Mac环境下搭建Rails开发环境是许多Ruby on Rails开发者的一项基本技能。本文将详细介绍如何在Mac系统上搭建一个完整的Rails开发环境,包括Ruby环境配置、Rails框架...
Ruby on Rails是一个基于Ruby语言的开源Web开发框架,它遵循模型-视图-控制器(MVC)架构模式,旨在提高开发效率和代码可读性。Rails的安装过程是每个想要涉足这个领域的开发者都需要掌握的基础知识。下面将详细介绍...
在Web开发领域,Ruby与Rails框架的组合尤其受到欢迎。Rails遵循Model-View-Controller(MVC)设计模式,这种模式是软件工程中用于组织应用程序代码的一种结构化方式。在本篇中,我们将深入探讨Ruby模仿Rails MVC的...
```bash gem install rails ``` #### 致谢 文档特别感谢Marcos Tapajós的贡献以及Daniel Lopes为本书设计的封面。同时,文档还感谢了Ruby on Rails巴西社区及China on Rails社区的朋友们提供的帮助和支持。这些...
```bash rails generate crud_generator2 ModelName ``` 这里的`ModelName`是你需要创建的模型名称。这个命令将会生成相应的模型文件、控制器文件、视图文件以及数据库迁移文件。 **4. 自定义生成的代码** 虽然...
Rails 2.3.2 是一个古老的 Ruby on Rails 框架版本,它在 Ruby 社区中曾经广泛使用。Gem 是 Ruby 的包管理器,用于安装和管理各种库和框架,包括 Rails。如果你无法通过网络升级或安装 Rails,可以采用本地安装包的...
Ruby on Rails,简称Rails,是一款基于Ruby语言的开源Web应用框架,它遵循MVC(Model-View-Controller)架构模式,旨在使Web开发更简洁、高效。Rails强调“约定优于配置”,大大减少了开发者需要编写的配置代码。在...
在Ubuntu服务器上搭建Rails生产环境是一项关键的任务,它涉及到多个步骤和组件的配置。Rails是Ruby的一个框架,用于构建Web应用程序。在这个过程中,我们将主要关注以下几个核心知识点: 1. **Ruby 安装**:首先,...
### Ubuntu 下 Ruby on Rails 的安装与配置 #### 一、Ruby on Rails 的安装步骤 **1.1 系统环境准备** 确保您的 Ubuntu 系统已更新至最新状态。这一步很重要,因为新版本通常会修复旧版本中存在的问题,包括安全...
在Ruby on Rails框架中,与SQLServer 2000集成可能会比与其他常见的数据库系统(如MySQL或PostgreSQL)稍复杂一些,因为SQLServer 2000的兼容性问题和缺少官方支持。然而,通过一些第三方库和适当的配置,我们仍然...
在本教程中,我们将深入探讨如何在Windows操作系统上搭建Rails 2.2.2的开发环境。Rails是一个基于Ruby编程语言的开源Web应用程序框架,它遵循MVC(模型-视图-控制器)架构模式,使得Web开发变得更加简洁高效。本文将...
Ruby on Rails,简称Rails,是一款基于Ruby语言的开源Web应用程序框架,它遵循MVC(Model-View-Controller)架构模式,旨在使Web开发过程更加高效、简洁。在本篇文章中,我们将深入探讨Rails的安装过程,以及在这个...