I think i am missing something silly here , but cannot figure out and its been more than an hour trying. So without wasting time ..
I want to fetch index action in Users controller using json.
For example localhost:3000/users.json right now gives me data ..
[{"id":17,"url":"http://localhost:3000/users/17.json"},{"id":16,"url":"http://localhost:3000/users/16.json"}]
But i have other attributes in User table like first_name and last_name etc.. which i would like to use from json.
How should i modify my existing method to get the required details.
# GET /users
# GET /users.json
def index
@users = User.all
end
private
# Use callbacks to share common setup or constraints between actions.
def set_user
@user = User.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def user_params
params.require(:user).permit(:avatar, :first_name, :last_name)
end
indexaction. It's likely that you've not added extra parameters there.