开发者

Rest-Client usage ruby on rails

开发者 https://www.devze.com 2023-04-12 23:30 出处:网络
I have a ruby controller class with a def create. I am using rest client to get to a web page such as go开发者_运维问答ogle. basically this is my code ignore the other details related to creating sinc

I have a ruby controller class with a def create. I am using rest client to get to a web page such as go开发者_运维问答ogle. basically this is my code ignore the other details related to creating since.

 def create
  RestClient.get 'http://google.com'
  @smsclass = Smsclass.new(params[:smsclass])

  respond_to do |format|
   if @smsclass.save
     format.html { redirect_to RestClient.get 'http://google.com'}
     format.html { redirect_to @smsclass, :notice => 'Smsclass was successfully created.' }
     format.json { render :json => @smsclass, :status => :created, :location => @smsclass }
   else
     format.html { render :action => "new" }
     format.json { render :json => @smsclass.errors, :status => :unprocessable_entity }
   end
 end

end

I have required rest client. Let me know whats wrong. Thakn You.


redirect_to follows an url not the 'result' of that url.

Just do format.html { redirect_to 'http://google.com'} if you want it to go on google.

0

精彩评论

暂无评论...
验证码 换一张
取 消