我正在尝试构建一些非常简单的东西,但我有点困惑。我有一个具有 2 个操作、索引和标识的客户控制器。这些动作的视图每个都简单地显示一个图像。我想要做的是能够在 ios 应用程序发送一个简单的 json 获取请求时从索引视图更改为标识视图(它可以是发布的,并不重要,因为我只想更改视图)。我的customer_controller.rb 是
def index
respond_to do |format|
format.html # index.html.erb
format.json {render 'identification'}
end
end
def identification
@date = Time.now.strftime("%A, %d %B %Y")
@time = Time.now.strftime("%H:%M %p")
end
我的 routes.rb 是
get "customer/index"
post "customer/index"
get "customer/identification"
谁能指出我做错了什么的正确方向?每当 ios 应用程序发送 json 时,什么都不会发生。