尝试在rails控制器中使用respond_to和respond_with时,继续获取ActionController:UnknownFormat错误.控制器中以下行出错.
respond_with @surveys
Run Code Online (Sandbox Code Playgroud)
在/ app/assets/controllers/surveys_controller中
respond_to :json
def index
@surveys = Survey.all
respond_with @surveys
end
Run Code Online (Sandbox Code Playgroud)
在/config/routes.rb中
WebInsight::Application.routes.draw do
scope :api do
resources :surveys, defaults: {format: 'json'}
end
resources :surveys
end
Run Code Online (Sandbox Code Playgroud)
在/app/assets/views/surveys/index.html.erb中
<h1>Your Surveys</h1>
<form>
<input type="text" ng-model='newSurvey' placeholder="Enter a survey">
<input type="submit" value="Add">
</form>
<div ng-controller="SurveysCtrl">
<ul>
<li ng-repeat="survey in surveys">
{{ survey.theme_id }}, {{ survey.name }}, {{ survey.description }}
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
在/app/assets/javascripts/angular/controllers/surveys_ctrl.js中
app.controller('SurveysCtrl', ['$scope', '$resource', function($scope, $resource) {
var Surveys = $resource('/api/surveys');
$scope.surveys = Surveys.query();
}]);
Run Code Online (Sandbox Code Playgroud) 我正在尝试在AWS Beanstalk上传我的rails项目.
我已经运行了eb init,eb start并配置了数据库设置以指向RDS.在我推动使用git aws.push并等待启动AWS服务器之后,提供的链接说:
"502 Bad Gateway nginx"
Run Code Online (Sandbox Code Playgroud)
在日志中
-------------------------------------
/var/app/support/logs/passenger.log
-------------------------------------
App 6861 stderr: [ 2014-05-29 13:26:59.1308 6893/0x00000001e50050(Worker 1) utils.rb:68 ]:
*** Exception RuntimeError in Rack application object (Missing `secret_key_base` for
'production' environment, set this value in `config/secrets.yml`) (process 6893, thread
0x00000001e50050(Worker 1)):
Run Code Online (Sandbox Code Playgroud)
在我的秘密.yml
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Run Code Online (Sandbox Code Playgroud) passenger amazon-web-services ruby-2.0 ruby-on-rails-4.1 amazon-elastic-beanstalk