Look interesting right? :)
It change my perspective. Why don't you try it!
It change my perspective. Why don't you try it!
namespace :admin do resources :menus do resources :menu_items end endI think it's probably common used case. Unfortunately, I got this error when I try to create a new MenuItem in menu_items/_form.html.erb
undefind method 'admin_menu_items_path' for #<#<Class ... ... 1: <%= form_for(@admin_menu_item)do |f| %> ... 17: endI realize that the standard scaffolding won't work for me, so I start googling. Right away, I get a lot of hits. It's seem to be a common issue. However, the solutions create quite a confusion for me. I try different solutions, some looking good but don't work! .. Here is what I find working.
def new @menu = Admin::Menu.find(params[:menu_id]) @menu_item = @menu.menu_items.build ... endIt load up the @menu, and build @menu_item, nothing surprise me. I also get rid of than "admin" prefix. It's simpler that way.
1: def perms(L) 2: return [[]] if L.size == 0 3: result = [] 4: L.each do |elm| 5: L1 = L - [elm] 6: perms(L1).each |p| 7: p1 = [elm] + p 8: result << p1 9: end 10: end 11: return result 12: end
1 + 2 + 3 + ... + 100 100 + 99 + 98 + ... + 1 --------------------------------------- 101 + 101 + 101 + ... + 101 = 101 * 100
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js? config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
class Duck attr_reader :name attr_accessor :fly_behavior, :quack_behavior def initialize @name = "mallard duck" @fly_behavior = nil @quack_behavior = nil end def fly fly_behavior.fly end def quack quack_behavior.quack end end
require './duck' require './behavior/fly_with_wing' require './behavior/quack_loud' class MallardDuck < Duck def initialize @name = "mallard duck" @fly_behavior = Behavior::FlyWithWing.new @quack_behavior = Behavior::QuackLoud.new end end