in my application I want set textfield value dynamically coming from header. Here is the code
in android project I set on header latitude ang longitude and I am trying get this on rails view.
public static String getAddress(final String dir_atoken, final String data_atoken, final float lat, final float lng) throws Exception {
final HttpGet get = new HttpGet("http://192.168.1.4:3000/address/lookup");
get.setHeader(LAT,String.valueOf(lat));
get.setHeader(LNG,String.valueOf(lng));
return getResponse(get, 200, true);
}
this is my lookup_address controller
def lookup_address
@lat = request.headers['Lat']
@lng = request.headers['Lng']
end
this is my lookup_address.html.erb
<% form_for @location do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :latitude %><br />
<%= f.text_field :latitude, :value => request.headers['Lat'] %>
</p>
<p>
<%= f.label :longitude %><br />
<%= f.text_field :longitude, :value => request.headers['Lng'] %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
When I set :value =>request.headers['Lat'] it always return null.
What should I do here for not getting null value?
Where the
@locationis built? Guess it will be more correct to set@location.latitudeand@location.longitudein controller.lookup_address.html.erb