Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArgumentError (too few arguments): when calling format.json on rails 4.04

When executing

format.json{render json: {}, status: :ok} 

in Rails 4.0.4, I get the following error:

ArgumentError (too few arguments): 

Although I have another program (with Rails 3.2.13) where the exact same line executes with no problem. am I missing something here?

any gems?

or change in syntax with rails 4?

like image 227
juan Isaza Avatar asked May 07 '14 19:05

juan Isaza


1 Answers

Mostly you would get the error ArgumentError (too few arguments): on the format when you forget to call this part of code within the block to respond_to method call.

Your code should actually look like

def action_name   respond_to do |format|  ## Add this     format.json { render json: {}, status: :ok}     format.html      ## Other format   end                    ## Add this end 
like image 80
Kirti Thorat Avatar answered Sep 21 '22 20:09

Kirti Thorat