Below is my index action:
def index
@api = Api.find_by(name: params[:name])
@descriptions = @api.descriptions.all
if valid_json?(@descriptions.first.value)
render json: JSON.pretty_generate(JSON.parse(@descriptions.first.value))
else
flash[:danger] = "Something wrong with your JSON data."
redirect_to root_path
end
end
when I use url "http://localhost:3000/xxxxxxxx?name=1234567890" It will return data in JSON format.
However, if I change params[:name] to params[:action] and url to "http://localhost:3000/xxxxxxxx?action=1234567890", then it will not work anymore.
I know it is because params[:action] is equal index in this case, but is there any way I can still pass params[:action]=12345 or whatever I use in url?