资源说明:my first rails project base on enki
h1. Enki A Ruby on Rails blogging app for the fashionable developer. Preferences are for the masses. Any real coder knows the easiest and best way to customize something is by *hacking code*. Because you want your blog to be you, not bog standard install #4958 with 20 posts per page instead of 15. For this you need a *clean, simple, easy to understand code base* that stays out of your way. No liquid drops and templates hindering your path, no ugly PHP(Hypertext Preprocessor) stylings burning your eyeballs. h2. Quick Start make sure you are using **ruby 1.8.7**,you can controle ruby's version by rvmOr for bonus points, fork "enki at github":https://github.com/jhjguxin/enki/commits/master and clone that instead. h2. More info Enki is a compact, easily extendable base for your blog. It does this by being highly opinionated, for example: * Public facing views should adhere to standards (XHTML(eXtensible Hypertext Markup Language), Atom) * /yyyy/mm/dd/post-title is a good URL for your posts * Live comment preview should be provided by default * Google does search better than you or I * You don't need a plugin system when you've got decent source control * #If you're not using OpenID you're a chump * Because I'm a chump,so I decide to use devise * Hacking code is the easiest way to customize something h2. How it differs from Mephisto Mephisto is feature packed and quite customizable. It can however be daunting trying to find your way around the code, which isn’t so good if you’re trying to hack in your own features. Enki strips out a lot of the features that you probably don’t need (multiple authors and liquid templates, for example), and focuses on keeping a tight code base that is easy to comprehend and extend. h2. How it differs from SimpleLog Enki embodies much of the philosophy of SimpleLog, but does so in a style that is much more consistent with Rails best practices, making it easier to understand and hack the code. h2. Compatibility Uses rails 3. Runs on MySQL or Postgres. Works on heroku. h2. Contributors, these guys rockgit clone git://github.com/jhjguxin/enki.git cd enki git checkout -b myblog # Create a new work branch bundle install # Install all the required gems cp config/database.example.yml config/database.yml # Edit config/enki.yml and config/database.yml to taste # Next step needs libxml2 and libxslt1 and their headers # On Debian-based systems: apt-get install libxml2-dev libxslt1-dev # On Mac OS X: no action required rake db:migrate #may be here will display some 'WARNING' message,but it no effect with rails's wrok,like ***WARNING:*** 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead. rake # Run tests rails server # Start the server # Load http://localhost:3000/admin in your browser
If you want to help out, try tackling an "open issue":https://github.com/jhjguxin/enki/issues. Please include specs for any fixes. Enki is by design feature light. Unless you feel very strongly your feature should be in core, add a link to your fork in the wiki instead. h2. License GPL(General Public License) - See LICENSE Admin design heavily inspired by "Habari":http://www.habariproject.org/en/ h2. QA Showing the devise edit password screen? In my rails 3 app using devise, I want to provide a link for users to edit their password. I have a standard link that points to: /users/password/edit ... Log output below(#all action in PasswordsController )git log | grep Author | sort | uniq
Why is rails redirecting? Why can't I show the edit password page? ThanksStarted GET "/users/password/edit" for 127.0.0.1 at 2011-08-10 10:11:46 -0700 Processing by Devise::PasswordsController#edit as HTML User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1 Redirected to http://localhost:3000/ Completed 302 Found in 309ms
Devise::PasswordsController#edit
is for non-authenticated users who wish to change their password using a reset token. This reset token was previously sent to the user in an email (Reset password instructions). If the user is already logged in, this edit password page will always redirect to the after-sign-in path since it shouldn't be accessible to authenticated users. I suppose what you want is to allow the user to change his password after logging in. You have to useDevise::RegistrationsController#edit
for that. #sometimes you will catchYou have already activated rack 1.3.0, but your Gemfile requires rack 1.2.3.
这是因为迩安装了多个rack版本、环境造成混乱、请卸载掉不需要的版本或者修改了Gemfile再执行一次bundle install h2. Fix by FrancisLesstile::CodeRayFormatter
in lesstile not match with coderay 1.0.1 install lesstile with pluginrails plugin install git://github.com/xaviershay/lesstile.git
change lesstile.rb in 'vendor/plugins/lesstile/lib' as bellow:h2. add rvm in ubuntu#CodeRay.scan(CGI::unescapeHTML(code), lang).html(:line_numbers => :table).div CodeRay.scan(CGI::unescapeHTML(code), lang).div(:line_numbers => :table)
h3. add rvm group to user#install Dependencies: sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion sudo apt-get install ruby-rvm
h3. add rvm to shell vim ~/.bashrc [[ -s "/usr/share/ruby-rvm/scripts/rvm" ]] && source /usr/share/ruby-rvm/scripts/rvm # This loads RVM into a shell session.没有引号 restart the shell opened If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output 'rvm is a function' as shown below. user$ type rvm | head -1 rvm is a function RVM安装完成后,就可以通过TA来安装管理 Ruby 了。用下面一条命令来安装Ruby 1.9.2 $ rvm install 1.9.2 *Ruby包的下载实在太慢了,这里总是中断。有个小技巧,你可以用工具下载好ruby-1.9.2-p0.tar.bz2,然后手工放到~/.rvm/archives 目录下。然后再运行这条命令,就可以直接解压安装了。 把该版本的Ruby设为默认 rvm --help 获得rvm的常用用法: rvm [Flags] [Options] Action [Implementation[,Implementation[,...]] rvm最常用的Action包括: 对Ruby的操作 主要包括读取,安装,卸载,更新,读取ruby等. 读取远程可安装的Ruby版本 #获得当前可以用的ruby版本 rvm list known 安装Ruby #安装其中的ruby1.9.2-p290 rvm install ruby-1.9.2-p290 使用 #切换到刚刚安装的ruby1.9.2-p290版本 rvm use ruby1.9.2-p290 读取 #列出当前rvm下的ruby版本 rvm list #查询当前使用的ruby版本路径 which ruby #获得当前ruby版本 ruby -v 输出rvm当前使用的ruby版本与gemset信息: rvm info 在项目文件中使用RVM 在自己的项目根目录下面,创建一个.rvmrc文件,里面内容可以指定ruby版本与gemset。例如,某项目根目录下面的.rvmrc文件内容如下: rvm ruby-1.9.2-p290@rails31 这表示,该项目使用ruby1.9.2p290这个版本的ruby,gem安装在rails31下面。然后iterm的zsh或者bash;或者TextMate中的rubymate,rakemate;以及pow等工具就可以直接调用相应ruby版本与相应gemset。 h2. rvm on ubuntu 11.10 install ruby 1.9.2 error When trying to install ruby 1.9.2 using rvm I got a nasty suprise:jhjguxin@jhjguxin-virtual-machine:~$ sudo gpasswd -a root rvm Adding user root to group rvm jhjguxin@jhjguxin-virtual-machine:~$ sudo gpasswd -a jhjguxin rvm Adding user jhjguxin to group rvm jhjguxin@jhjguxin-virtual-machine:~$ sudo gpasswd -a www-data rvm Adding user www-data to group rvm
The solutionossl_ssl.c:110:1: error: ‘SSLv2_method’ undeclared here (not in a function) ossl_ssl.c:111:1: error: ‘SSLv2_server_method’ undeclared here (not in a function) ossl_ssl.c:112:1: error: ‘SSLv2_client_method’ undeclared here (not in a function) make[1]: *** [ossl_ssl.o] Error 1 make[1]: Leaving directory `/var/cache/ruby-rvm/src/ruby-1.9.2-p180/ext/openssl' make: *** [mkmain.sh] Error 1
h2. Quickstart sunspot with Rails 3 Add to Gemfile:sudo apt-get install ruby-rvm # make sure we have $rvm_path source /etc/profile # don't use ubuntus openssl rvm package install openssl rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr
Bundle it!gem 'sunspot_rails' gem 'sunspot_solr' # optional pre-packaged Solr distribution for use in development
bundle install
Generate a default configuration file:rails generate sunspot_rails:install
If sunspot_solr was installed, start the packaged Solr distribution with:bundle exec rake sunspot:solr:start # or sunspot:solr:run to start in foreground
Now that Sunspot knows how to index the Post model, we need to get the existing data into Solr. Any time a Post is created, updated, or destroyed, Sunspot::Rails will automatically make the change to the index; you only need to do a full reindex if you’ve added or changed a searchable definition for a model.$ rake sunspot:reindex
If sunspot_solr was installed, start the packaged Solr distribution with:Try to start the solr Solr服务控制 将以上内容添加到Rakefile后,将会多出4个task出来 服务器启动: rake sunspot:solr:start 初次启动,会安装一个embed的solr程序,那么开发环境中省去了安装配置Solr环境繁琐步骤。不过,production环境里可不要使用这个embed版。 服务器停止: rake sunspot:solr:stop 全部重建索引: rake sunspot:reindex 如果你想看到运行日志,把服务跑在前端。可以使用一下命令: rake sunspot:solr:run 使用以上命令,就能完成对Sunspot的控制。 h3. when you get "RSolr::Error::Http (RSolr::Error::Http - 500 Internal Server Errorjhjguxin@jhjguxin-Aspire-4750:~$ heroku run:detached rake sunspot:solr:start RAILS_ENV=production rake sunspot:solr:start --app francisjiang#using on heroku or type:sunspot-solr start -- -p 8983 or sunspot-solr start -- -p 8983 -d data/solr/myapp
h2. the feature in the future 1. add reploy to reploy 2. finish the permission control 3. 使用验证码 4. Mention @somebody. They're notified eg. When you @mention a GitHub username anywhere in the context of an issue or pull request, that person is notified and subscribed to future updates. 5. @自动匹配用户名功能Error: Severe errors in solr configuration." in log please navigation to "localhost:8082/solr" check more info: there recomment method is ps -ef|grep solr kill all solr's process rm solr folder in enki root dir.reinstall the solr by type: #Generate a default configuration file: rails generate sunspot_rails:install
If sunspot_solr was installed, start the packaged Solr distribution with:bundle exec rake sunspot:solr:start # or sunspot:solr:run to start in foreground
Now that Sunspot knows how to index the Post model, we need to get the existing data into Solr. Any time a Post is created, updated, or destroyed, Sunspot::Rails will automatically make the change to the index; you only need to do a full reindex if you’ve added or changed a searchable definition for a model.$ rake sunspot:reindex
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。