我想要生成new.json.rabl页面来创建新的帖子,首先我在post文件夹new.json.rabl文件中创建了
object @post
attributes :content, :photo和localhost:3000/post/new.json返回
{"post":{"content":null,"photo":null}}如何向rabl发送内容和照片值?
发布于 2014-12-10 10:41:20
您可能在posts控制器中有一个新方法。在这里,如果希望rabl呈现内容和照片值,则需要放置:
def new
@post = Post.new(content: "some_content", photo: "some_photo")
render('path_to_your_rabl_file', formats: :json) # or respond_with(@post) if the routes are correct
endhttps://stackoverflow.com/questions/27397780
复制相似问题