ruby on rails - Wrapping user_params in an array Android -


i trying pass user sign details rails user controller. while rails rails creates form tag using @user object, not know how same android. using following code send post request using volley.

public class register extends activity {  button btnlogin; edittext inputusername; edittext inputemail; edittext inputpassword; edittext inputpasswordconfirmation;  @override protected void oncreate(bundle savedinstancestate) {     // todo auto-generated method stub     super.oncreate(savedinstancestate);     setcontentview(r.layout.register);      inputusername = (edittext) findviewbyid(r.id.fld_username);     inputemail = (edittext) findviewbyid(r.id.fld_email);     inputpassword = (edittext) findviewbyid(r.id.fld_pwd);     inputpasswordconfirmation = (edittext) findviewbyid(r.id.fld_pwd_confirm);     btnlogin = (button) findviewbyid(r.id.btn_login);      final requestqueue queue = volley.newrequestqueue(this);      btnlogin.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             final string username = string.valueof(inputusername.gettext());             final string email = string.valueof(inputemail.gettext());             final string password = string.valueof(inputpassword.gettext());             final string passwordconfirmation = string.valueof(inputpasswordconfirmation.gettext());              stringrequest postrequest = new stringrequest(request.method.post,                     "http://community.ngrok.com/users", new response.listener<string>() {                 @override                 public void onresponse(string s) {                     log.d("response", s);                 }             }, new response.errorlistener() {                 @override                 public void onerrorresponse(volleyerror volleyerror) {                     log.d("error",volleyerror.tostring());                 }             }){                 @override                 protected map<string,string> getparams(){                     map<string, string> params = new hashmap<string, string>();                     params.put("name", username);                     params.put("email",email);                     params.put("password", password);                     params.put("password_confirmation", passwordconfirmation);                     return params;                 }             };              queue.add(postrequest);              intent home = new intent(getapplicationcontext(), mainactivity.class);             startactivity(home);          }     }); } 

}

my rails new.html.erb sign code

<% provide(:title, 'sign up') %> <h1>sign up</h1>  <div class="row"> <div class="col-md-6 col-md-offset-3"> <%= form_for(@user) |f| %>   <%= render 'fields', f: f %>   <%= f.submit "create account", class: "btn btn-primary" %> <% end %> </div> </div> 

the error when send post request

actioncontroller::parametermissing (param missing or value empty: user): app/controllers/users_controller.rb:73:in `user_params' app/controllers/users_controller.rb:21:in `create' 

so question how wrap user_params in array using volley in order have @user object

thats cannot do/ or not easy in android. serializeable class exits in android(java) implementation way different. need extract data post etc. http in order use it.


Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -