dhendy ferdian wrote:
> di controllernya bikin konstanta
> SUCCESS = "Your changes have been saved.".freeze
> ERROR = "Please check below for any highlighted mistakes...".freeze
>
> def create
> .....
> if @threshold.save
> flash[:notice] = SUCCESS
> redirect_to :action => 'list'
> else
> flash[:notice] = ERROR
> render :action => 'new'
> end
> ......
> end
OK, bagus, jujur saya "merasa" ada yg kaku di konstanta di controller dhendy.
Kalau saya "merasa" lebih fleksibel dengan cara:
if @obyek.save
rea_list 'Pesan kowe keno notis ndes'
else
ren_new 'Kowe keno error le'
end
protected
def rea_list(msg = nil)
flash[:notice] = msg unless msg.nil?
redirect_to :action => 'list'
end
def ren_new(msg = nil)
flash[:error] = msg unless msg.nil?
render :action => 'new'
end
hayo adit, gw racuni refactor lo, masi bisa direfactor lagi tuh dit ... nanti lo
jadiin plugin ya. (yg reply gw satunya, kalo lebih dari 3 biji). gw tunggu reply
dengan URL svnnya, kalo buat adit gw mau ikutan bantuin coding rails plugin.
# ngelirik jedi andry.. kaburr silau pedangnya dia.
> kurang lebih nya gitu .... :)
ya, sama-sama. mau nyontek dhendy ah ngomong ke adit, kurang lebihnya gitu dit..
-_-
--
$ ruby-19 -e "puts ({name:'arie', blog:'http://ariekusumaatmaja.wordpress.com',
community:%w(http://groups.yahoo.com/groups/id-ruby
http://www.linkedin.com/in/ariekeren)}).is_a?(Hash).to_s.concat(' erl ghc z')"
true erl ghc z