Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Gary 's Profile

GitHub User: zxlai

Site: garylai.ch

Comments by Gary

Avatar

I tried to add more entities. After I add more entities, I tries to add data and I got 422 status. And this is my code:

app/controllers/posts_controller.rb
class PostsController < ApplicationController
  respond_to :json

  def index
    respond_with Post.all
  end

  def show
    respond_with Post.find(params[:id])
  end

  def create
    respond_with Post.create(params[:post])
  end

  def update
    respond_with Post.update(params[:id], params[:post])
  end

  def destroy
    respond_with Post.destroy(params[:id])
  end
end
app/assets/javascripts/news.js.coffee
app = angular.module("newsApp", ["ngResource"])

app.factory "Post", ["$resource", ($resource) ->
  $resource("/posts/:id", {id: "@id"}, {update: {method: "PUT"}})
]

@NewsCtrl = ["$scope", "Post", ($scope, Post) ->
  $scope.posts = Post.query()

  $scope.addPosts = ->
    post = Post.save($scope.newPost)
    console.log(post)
    $scope.posts.push(post)
    $scope.newPost = {}
]
app/views/news/index.html.erb
<div ng-controller="NewsCtrl">
  <form ng-submit="addPosts()">
    <input type="text" ng-model="newPost.title">
    <input type="text" ng-model="newPost.content">
    <input type="text" ng-model="newPost.source">
    <input type="submit" value="Add">
  </form>
  <ul>
    <li ng-repeat="post in posts">
      {{post.title}}
      {{post.content}}
      {{post.source}}
    </li>
  </ul>
</div>

Can I use this way?

Avatar

Thanks for this episode. It's very clearly, but I have some error on this episode.

I asked on stackoverflow, but there're no one can answer me. Hope can help me. Thanks!

http://stackoverflow.com/questions/11793788/gem-koala-undefined-methods-get-object

Avatar

I also met some problem .

/config/initializers/omniauth.rb
OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET']
end

When I put the first lineOmniAuth.config.logger = Rails.logger in this file, I run rails s , and the terminal said:

/Users/laigary/Documents/rails/nckucourse/config/initializers/omniauth.rb:1:in `<top (required)>': undefined method `logger=' for #<OmniAuth::Configuration:0x007fd4d3a34c38> (NoMethodError)
...
...
...

When I delete the first line OmniAuth.config.logger = Rails.logger , it works.

How can I solve this problem?

Avatar

Thanks, but it seems set in my computer, doesn't it?
I ask this question on the stackoverflow as well. Someone said :
"You just add this ENV['FACEBOOK_APP_ID'] = "yourapikey" into config/environments/development.rb or config/environments/production.rb"

What's the different?

Avatar

Sorry, I'm first time to use omniauth. and have question about ENV["FACEBOOK_APP_ID"]

Should I replace FACEBOOK_APP_ID to my facebook app id, or I should set FACEBOOK_APP_ID in somewhere?