锘??xml version="1.0" encoding="utf-8" standalone="yes"?>2222www色视频在线观看,欧美日韩精品免费观看视欧美高清免费大片 ,91精品久久久久久9s密挑http://www.aygfsteel.com/martian/archive/2009/04/15/265686.html Martian Martian Wed, 15 Apr 2009 02:57:00 GMThttp://www.aygfsteel.com/martian/archive/2009/04/15/265686.htmlhttp://www.aygfsteel.com/martian/comments/265686.htmlhttp://www.aygfsteel.com/martian/archive/2009/04/15/265686.html#Feedback0http://www.aygfsteel.com/martian/comments/commentRss/265686.htmlhttp://www.aygfsteel.com/martian/services/trackbacks/265686.html 鍋囧榪欐牱涓涓満鏅細
routes.rb涓繖鏍峰畾涔?
map.namespace :admin do |admin|
    admin.resources :articles
    admin.resources :tags
end

闇瑕佸articles,tags鎻愪緵涓涓粺涓鐨勫悗鍙扮鐞嗙晫闈紝鏍規嵁rails涓殑layout鍔熻兘錛岀寽鎯蟲槸鍚︿細鏈塴ayouts/admin.html.erb榪欐牱涓涓拡瀵筺amespace鐨勬ā鏉塊〉錛屼絾灝濊瘯鍚庡彂鐜版牴鎹笉琛岋紝涓嬮潰鏄痝oogle鍒扮殑涓涓棶棰橈細

Do controllers in namespaces somehow get their own default layout
file
?  For instance, the UsersController will use layouts/users.rhtml
if it exists.  Is there something similar for Admin::UsersController
or will it 
default to the same file?  I tried layouts/
admin_users.rhtml and layouts
/admin/users.rhtml with no luck.

浠栦篃灝濊瘯浜嗗悓鏍風殑闂錛?span style="color: #000000;">layouts/users.rhtml, layouts/admin_users.rhtml, layouts/admin/users.rhtml錛岄兘鏄痭o luck.

榪欓噷鍙互浣跨敤涓涓彇宸х殑鏂規硶錛屽湪controller涓彲浠ラ氳繃layout 鏂規硶鏉ユ寚瀹氫嬌鐢ㄥ摢涓ā鏉塊〉錛岃繖閲屽彲浠ュ啓涓涓狟aseController:
class Admin::BaseController < ApplicationController
  layout 
'admin'
end

鍦˙aseController涓寚瀹氭ā鏉塊〉涓篴dmin.html.erb

鐒跺悗灝哸rticles鍜宼ags鐨凜ontroller閮芥敼涓虹戶鎵胯嚜BaseController銆?

Martian 2009-04-15 10:57 鍙戣〃璇勮
]]>
Rails涓殑namespacehttp://www.aygfsteel.com/martian/archive/2009/04/10/264882.html Martian Martian Fri, 10 Apr 2009 08:56:00 GMThttp://www.aygfsteel.com/martian/archive/2009/04/10/264882.htmlhttp://www.aygfsteel.com/martian/comments/264882.htmlhttp://www.aygfsteel.com/martian/archive/2009/04/10/264882.html#Feedback0http://www.aygfsteel.com/martian/comments/commentRss/264882.htmlhttp://www.aygfsteel.com/martian/services/trackbacks/264882.html 棣栧厛鐢熸垚scaffold:
script/generate scaffold article title:string body:text
鍦╮outes.rb涓坊鍔犲涓嬭礬鐢憋細
map.namespace :admin do |admin|
    admin.resources :articles
end

鐢辨剰鍛崇潃緇檃rticle澧炲姞浜嗕竴涓悕涓篴dmin鐨刵amespace,灝哻ontrollers涓殑articles_controller.rb淇敼涓篶ontrollers/admin/articles_controller.rb錛屼篃灝辨槸灝嗚繖涓帶鍒跺櫒鏀懼埌admin榪欎釜鏂囦歡澶逛腑銆?br />
鍏堢湅涓涓嬬浉搴旂殑璺敱瑙勫垯,鎵цrake roures:
              admin_articles GET    /admin/articles                  {:action=>"index", :controller=>"admin/articles"}
    formatted_admin_articles GET    
/admin/articles.:format          {:action=>"index", :controller=>"admin/articles"}
                             POST   
/admin/articles                  {:action=>"create", :controller=>"admin/articles"}
                             POST   
/admin/articles.:format          {:action=>"create", :controller=>"admin/articles"}
           new_admin_article GET    
/admin/articles/new              {:action=>"new", :controller=>"admin/articles"}
 formatted_new_admin_article GET    
/admin/articles/new.:format      {:action=>"new", :controller=>"admin/articles"}
          edit_admin_article GET    
/admin/articles/:id/edit         {:action=>"edit", :controller=>"admin/articles"}
formatted_edit_admin_article GET    
/admin/articles/:id/edit.:format {:action=>"edit", :controller=>"admin/articles"}
               admin_article GET    
/admin/articles/:id              {:action=>"show", :controller=>"admin/articles"}
     formatted_admin_article GET    
/admin/articles/:id.:format      {:action=>"show", :controller=>"admin/articles"}
                             PUT    
/admin/articles/:id              {:action=>"update", :controller=>"admin/articles"}
                             PUT    
/admin/articles/:id.:format      {:action=>"update", :controller=>"admin/articles"}
                             DELETE 
/admin/articles/:id              {:action=>"destroy", :controller=>"admin/articles"}

                             DELETE 
/admin/articles/:id.:format      {:action=>"destroy", :controller=>"admin/articles"}

                                    
/:controller/:action/:id
                                    
/:controller/:action/:id.:format

瀵規瘮涓涓嬩笉鍔燼dmin榪欎釜namespace鏃剁殑璺敱錛?br />
          article_index GET    /article                         {:action=>"index", :controller=>"article"}
formatted_article_index GET    
/article.:format                 {:action=>"index", :controller=>"article"}
                        POST   
/article                         {:action=>"create", :controller=>"article"}
                        POST   
/article.:format                 {:action=>"create", :controller=>"article"}
            new_article GET    
/article/new                     {:action=>"new", :controller=>"article"}
  formatted_new_article GET    
/article/new.:format             {:action=>"new", :controller=>"article"}
           edit_article GET    
/article/:id/edit                {:action=>"edit", :controller=>"article"}
 formatted_edit_article GET    
/article/:id/edit.:format        {:action=>"edit", :controller=>"article"}
                article GET    
/article/:id                     {:action=>"show", :controller=>"article"}
      formatted_article GET    
/article/:id.:format             {:action=>"show", :controller=>"article"}
                        PUT    
/article/:id                     {:action=>"update", :controller=>"article"}
                        PUT    
/article/:id.:format             {:action=>"update", :controller=>"article"}
                        DELETE 
/article/:id                     {:action=>"destroy", :controller=>"article"}
                        DELETE 
/article/:id.:format             {:action=>"destroy", :controller=>"article"}
                               
/:controller/:action/:id
                               
/:controller/:action/:id.:format

鎵鏈夌殑璺敱瑙勫垯涓婇潰錛岄兘鍔犱笂浜哸dmin榪欎釜namespace銆?br />
涓嬮潰灝辮灝唙iews鐩綍涓嬮潰鐨刟rticles鐩綍鏀瑰埌views/admin鐩綍涓嬮潰錛屽洜涓烘牴鎹礬鐢辮鍒欙紝浼氬埌views/admin/articles/鐩綍涓嬮潰鍘繪煡鎵劇浉搴旂殑妯℃澘銆?br />
鍙﹀錛岃繕闇瑕佸皢鍘熸潵鐨刵ew_article_url | new_article_path絳塰elper鏂規硶淇敼涓簄ew_admin_article_url | new_admin_article_path錛屽皢榪欎簺helper鏂規硶鍏ㄩ儴鍔犱笂admin榪欎釜namespace銆?br />

Martian 2009-04-10 16:56 鍙戣〃璇勮
]]>
[杞琞Why I like Ruby #1: alias_methodhttp://www.aygfsteel.com/martian/archive/2009/04/03/263772.html Martian Martian Fri, 03 Apr 2009 08:18:00 GMThttp://www.aygfsteel.com/martian/archive/2009/04/03/263772.htmlhttp://www.aygfsteel.com/martian/comments/263772.htmlhttp://www.aygfsteel.com/martian/archive/2009/04/03/263772.html#Feedback0http://www.aygfsteel.com/martian/comments/commentRss/263772.htmlhttp://www.aygfsteel.com/martian/services/trackbacks/263772.htmlSo you found yourself in the need to override a method but still count on it’s old behaviour?

No problem! Override it with your new code, call super and…. Uh oh!! Suddenly this turned into a problem… Let me give some more context.

I was testing Ferret (and the acts_as_ferret plugin) in a project to provide full text search capabilities to our models. One of the things the plugin does is to add a new method to ActiveRecord, called find_with_ferret. That way, every model can use it. Great!

So I thought that would make sense for me to remove all diatrictics from the input text before letting ferret do its job. You know, like removing umlauts and all that.

I could do that by overriding this method with code to remove the undesired chars and then call its older version to finally do the search - something like calling super, but not quite. And I didn’t want my models to inherit from anything else than ActiveRecord::Base. That wouldn’t make any sense.

alias_method to the rescue!

You know that to redefine a method in an existing class you can open it up and rewrite it. But since you don’t wanna loose the behaviour provided by the original method, this is how you can achieve this:

module ActiveRecord
  
class Base
    alias_method :find_with_ferret_original, :find_with_ferret
 
    def find_with_ferret(q, options 
= {}, find_options = {})
      remove_diatrictics
!(q)
      find_with_ferret_original(q, options, find_options)
    end
  end
end

And you’re good to go. On line 3 you’re just giving the original method an alias, making a copy of it.

Then you redefine it the way you like and on line 6 you call the old version to make sure u still got the same behaviour.
Now all my models can benefit of this change without requiring them to call another method nor inherit from another class.

Cool, huh? :)



Martian 2009-04-03 16:18 鍙戣〃璇勮
]]>
淇敼Easy_Fckeditor涓婁紶鍥劇墖鐨勭洰褰?/title><link>http://www.aygfsteel.com/martian/archive/2009/04/03/263669.html</link><dc:creator> Martian </dc:creator><author> Martian </author><pubDate>Fri, 03 Apr 2009 01:32:00 GMT</pubDate><guid>http://www.aygfsteel.com/martian/archive/2009/04/03/263669.html</guid><wfw:comment>http://www.aygfsteel.com/martian/comments/263669.html</wfw:comment><comments>http://www.aygfsteel.com/martian/archive/2009/04/03/263669.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/martian/comments/commentRss/263669.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/martian/services/trackbacks/263669.html</trackback:ping><description><![CDATA[<strong>淇敼鏂囦歡涓婁紶鐩綍</strong><br /> easy_fckeditor榛樿鐨勬枃浠朵笂浼犵洰褰曚負<br /> public/uploads/Image錛屽叏閮ㄤ笂浼犵殑鍥劇墖閮戒細琚笂浼犵殑璇ョ洰褰曚笅錛屼負浜嗘柟渚跨鐞嗭紝灝嗕笂浼犵殑鍥劇墖鏍規嵁涓婁紶鏃ユ湡涓婁紶鍒頒笉鍚岀殑鏃ユ湡鐩綍涓嬶細<br /> 闇瑕佷慨鏀瑰嚑涓柟娉曪細<br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><span style="color: #000000;"> def current_directory_path<br />     base_dir </span><span style="color: #000000;">=</span> <span style="color: #000000;">"</span><span style="color: #000000;">#{UPLOADED_ROOT}/#{params[:Type]}/#{ Time.now.strftime('%Y%m%d') }</span><span style="color: #000000;">"</span><span style="color: #000000;"><br /> #    Dir.mkdir(base_dir, </span><span style="color: #000000;">0775</span><span style="color: #000000;">) unless File.exists</span><span style="color: #000000;">?</span><span style="color: #000000;">(base_dir)<br />     FileUtils.mkdir_p base_dir<br />     check_path(</span><span style="color: #000000;">"</span><span style="color: #000000;">#{base_dir}#{params[:CurrentFolder]}</span><span style="color: #000000;">"</span><span style="color: #000000;">)<br />     </span><span style="color: #000000;">"</span><span style="color: #000000;">#{base_dir}</span><span style="color: #000000;">"</span><span style="color: #000000;"><br />  end</span></div> <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><span style="color: #000000;">def upload_directory_path<br />     #    uploaded </span><span style="color: #000000;">=</span><span style="color: #000000;"> request.relative_url_root.to_s </span><span style="color: #000000;">+</span> <span style="color: #000000;">"</span><span style="color: #000000;">#{UPLOAD_FOLDER}/#{params[:Type]}</span><span style="color: #000000;">"</span><span style="color: #000000;"><br />     uploaded </span><span style="color: #000000;">=</span><span style="color: #000000;"> ActionController::Base.relative_url_root.to_s</span><span style="color: #000000;">+</span><span style="color: #000000;">"</span><span style="color: #000000;">#{UPLOADED}/#{params[:Type]}</span><span style="color: #000000;">"</span> <span style="color: #000000;">+</span> <span style="color: #000000;">"</span><span style="color: #000000;">/</span><span style="color: #000000;">"</span><span style="color: #000000;">  </span><span style="color: #000000;">+</span><span style="color: #000000;"> Time.now.strftime(</span><span style="color: #000000;">'</span><span style="color: #000000;">%Y%m%d</span><span style="color: #000000;">'</span><span style="color: #000000;">)<br />     </span><span style="color: #000000;">"</span><span style="color: #000000;">#{uploaded}#{params[:CurrentFolder]}</span><span style="color: #000000;">"</span><span style="color: #000000;"><br /> end</span></div> <br /> 涓昏鏄姞涓棩鏈?span style="color: #000000;">Time.now.strftime(</span><span style="color: #000000;">'</span><span style="color: #000000;">%Y%m%d</span><span style="color: #000000;">'</span><span style="color: #000000;">)</span>,灝嗕笂浼犲悗鐨勫浘鐗囦笂浼犲埌public/uploads/Image/20090403/鐩綍涓嬶紝濡傛灉瑕佹崲鍙︿竴縐嶅艦寮忥紝涔熷緢鏂逛究 錛屽皢<span style="color: #000000;">Time.now.strftime(</span><span style="color: #000000;">'</span><span style="color: #000000;">%Y%m%d</span><span style="color: #000000;">'</span><span style="color: #000000;">)鏀規垚鑷繁闇瑕佺殑灝卞彲浠ヤ簡銆?/span> <img src ="http://www.aygfsteel.com/martian/aggbug/263669.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/martian/" target="_blank"> Martian </a> 2009-04-03 09:32 <a href="http://www.aygfsteel.com/martian/archive/2009/04/03/263669.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Rails Plugin: Easy Fckeditorhttp://www.aygfsteel.com/martian/archive/2009/04/02/263634.html Martian Martian Thu, 02 Apr 2009 14:57:00 GMThttp://www.aygfsteel.com/martian/archive/2009/04/02/263634.htmlhttp://www.aygfsteel.com/martian/comments/263634.htmlhttp://www.aygfsteel.com/martian/archive/2009/04/02/263634.html#Feedback0http://www.aygfsteel.com/martian/comments/commentRss/263634.htmlhttp://www.aygfsteel.com/martian/services/trackbacks/263634.html ruby script/plugin install git://github.com/gramos/easy-fckeditor.git

#浣跨敤rake瀹夎fckeditor
rake fckeditor:install
** Installing FCKEditor Plugin version 0.8.1
Creating directory editor
Creating directory css
Creating directory behaviors
  Installing file disablehandles.htc
  Installing file showtableborders.htc
  Installing file fck_editorarea.css
  Installing file fck_internal.css
  Installing file fck_showtableborders_gecko.css
Creating directory images
  Installing file block_address.png
  Installing file block_blockquote.png
  Installing file block_div.png
.
.
.
  Installing file fckplugin.js
  Installing file _upgrade.html
  Installing file _whatsnew.html
  Installing file _whatsnew_history.html
** Successfully installed FCKEditor Plugin version 0.8.1

#鍦ㄩ渶瑕佷嬌鐢‵ckeditor鐨勯〉闈㈠紩鍏ckeditor.js鏂囦歡
<%= javascript_include_tag :fckeditor  %>

#浣跨敤fckeditor_textarea
<%= fckeditor_textarea :article, :body, {:toolbarSet => 'Easy', :width => '100%', :height => '300px'%>

#鏇磋緇嗙殑浣跨敤璇存槑錛屽彲浠ュ弬鐪媓ttp://github.com/gramos/easy-fckeditor/tree/master

瑙e喅涓婁紶鍥劇墖闂

1. 鍦ㄤ笂浼犲浘鐗囩殑鏃跺?rails2.2.2)錛屼細鍑虹幇濡備笅鐨勯敊璇細

NoMethodError (undefined method `relative_url_root' for #<ActionController::CgiRequest:0x594ab4c>):
瑙e喅鏂規硶鍙傝?http://github.com/salicio/fckeditor/commit/fcf8fbee8cfad3a3df0df50172e448727909ccb9
1. 灝?vendor/plugins/easy_fckeditor/app/controllers/fckeditor_controller.rb涓殑
uploaded = request.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"
淇敼涓?
uploaded = ActionController::Base.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"
2. 灝?vendor/plugins/easy_fckeditor/lib/fckeditor.rb涓殑
js_path = "#{controller.relative_url_root}/javascripts"
淇敼涓猴細
js_path = "#{ActionController::Base.relative_url_root}/javascripts"

2. 璇lugins鐗堟湰灝戝畾涔変簡涓涓彉閲忥細
浼氬嚭鐜板涓嬮敊璇細
NameError (uninitialized constant FckeditorController::UPLOADED):

淇敼寰堢畝鍗曪紝鍙淇敼
/vendor/plugins/easy_fckeditor/app/controllers/fckeditor_controller.rb,澧炲姞:
UPLOADED = "/uploads"

瀹屾垚涔嬪悗錛岃兘澶熸甯鎬笂浼犲浘鐗囷紝騫墮瑙堛?br />




Martian 2009-04-02 22:57 鍙戣〃璇勮
]]>
install ruby on rails, sqlite3, sqlite3-ruby under ubuntu8.10http://www.aygfsteel.com/martian/archive/2009/04/01/263360.html Martian Martian Wed, 01 Apr 2009 06:57:00 GMThttp://www.aygfsteel.com/martian/archive/2009/04/01/263360.htmlhttp://www.aygfsteel.com/martian/comments/263360.htmlhttp://www.aygfsteel.com/martian/archive/2009/04/01/263360.html#Feedback0http://www.aygfsteel.com/martian/comments/commentRss/263360.htmlhttp://www.aygfsteel.com/martian/services/trackbacks/263360.htmlnothing but the script I used:

#install Ruby and relative
apt-get install ruby


#install wget
sudo apt-get install wget

#install rubygems
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xzf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo ruby setup.rb
gem -v
1.3.1

# or update rubygems
sudo gem install rubygems-update -v 1.3.1

#install Rails and dependencies
gem install rails –include-dependencies -v=2.2.2


#install Sqlite3

apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev

apt-get install ruby1.8-dev libsqlite3-dev (required)


gem install sqlite3-ruby #compile this need libsqlite.h



Martian 2009-04-01 14:57 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 麦盖提县| 徐州市| 甘孜| 香河县| 阿鲁科尔沁旗| 江山市| 册亨县| 扶风县| 遵化市| 新丰县| 广南县| 霸州市| 恩平市| 阿坝县| 江孜县| 盐池县| 伽师县| 农安县| 伊春市| 图片| 绥德县| 华坪县| 石渠县| 菏泽市| 上虞市| 安达市| 广河县| 鄯善县| 山东| 甘洛县| 鞍山市| 平遥县| 汝州市| 通河县| 怀化市| 呼伦贝尔市| 奉贤区| 梓潼县| 丰镇市| 新邵县| 水城县|