Currently learning through a Udemy Course but changed the lecture to something I am more interested in developing.
Project Basis:
- using Gem Flightstats-flex to pull flight data
- trying to display associated info from a search query
Current setup
app/controllers/trackers_controller.rb
class TrackersController < ApplicationController
def search
#tracker = FlightTracker.new_from_lookup(params[:tracker])
render 'users/my_tracker'
end
end
app/models/flight_tracker.rb
class FlightTracker < ActiveRecord::Base
self.table_name='trackers'
def self.new_from_lookup(tracker)
flight_track = FlightStats::FlightStatus.by_flight_id(tracker)
# flight_position = FlightStats::FlightStatus.track_by_flight_id(tracker)
end
This is where the problem happens, when I remove # from flight_position = FlightStats::FlightStatus.track_by_flight_id(tracker)
the results overwrite the top
if I use the line only it displays and vice versa for the top line
app/views/users/my_tracker.html.erb the data does render
<h1>
My Tracker
</h1>
<h3>Search for Flights</h3>
<div id="tracker-lookup">
<%= form_tag search_trackers_path, method: :get, id: "tracker-lookup-form" do %>
<div class="form-group row no-padding text-center col-md-12">
<div class="col-md-10">
<%= text_field_tag :tracker, params[:tracker],
placeholder: "Stock ticker symbol", autofocus: true,
class: "form-control search-box input-lg" %>
</div>
<div class="col-md-2">
<%= button_tag(type: :submit, class: "btn btn-lg btn-success") do %>
<i class="fa fa-search"></i> Look up a tracker
<% end %>
</div>
</div>
<% end %>
</div>
<div class="well results-block">
<%=#tracker.inspect%>
<strong>ID: </strong> <%#= #tracker&.flight_id %>
<strong>Code: </strong> <%#= #tracker&.carrier_fs_code %>
<strong>Number: </strong> <%#= #tracker&.flight_number %>
<strong>Departure: </strong> <%#= #tracker&.departure_airport_fs_code %>
<strong>Arrival: </strong> <%#= #tracker&.arrival_airport_fs_code %>
<%# <strong>Departure Terminal: </strong> <%= #tracker&.departure_terminal %> %>
<%=#position.inspect%>
</div>
So when an user searches for a .by_flight_id , I want it to show the related data for .track_by_flight_id
Hoping to move to the next stage of more data associations after a query is completed.
As illustration for my comment
def self.new_from_lookup(tracker)
flight_track = FlightStats::FlightStatus.by_flight_id(tracker)
flight_position = FlightStats::FlightStatus.track_by_flight_id(tracker)
OpenStruct.new(flight_track: flight_track, flight_position: flight_position)
end
Then you'll need to rewrite template my_tracker.html.erb to handle new data structure
Related
I am bit lost somewhere, as I have build gallery with active storage and it's fine and I am able to see images and upload the images
Here is a screenshot
But one problem, as I try to create a new page for listing page, I am trying to get images on thumb page
<div class="row">
<div class="col-md-3">
<ul class="sidebar-list">
<li class="sidebar-item"><%= link_to "Your tools Listings", tools_path, class: "sidebar-link active" %></li>
</ul>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
Listings
</div>
<div class="panel-body">
<% #tools.each do |tool| %>
<div class="row">
<div class="col-md-2">
<%= tool.images %>
</div>
<div class="col-md-7">
<h4><%= tool.listing_name %></h4>
</div>
<div class="col-md-3 right">
<%= link_to "Update", listing_tool_path(tool), class: "btn btn-black-free-account" %>
</div>
</div>
<hr/>
<% end %>
</div>
</div>
</div>
</div>
it should be fine as long it shows a text-based of images see screenshot below
So I need to change these images as I am using the same method as the first screenshot, as the code below
<% if #tool.images.attached? %>
<div class="panel panel-default">
<div class="panel-heading">
Photo Display
</div>
<br>
<div class="row">
<% #tool.images.each do |image| %>
<div class="col-md-4">
<div class="panel panel-default tools-gallery-panel">
<div class="panel-heading preview ">
<%= link_to image_tag(image, class:"img-thumbnail tools-gallery"), image %>
</div>
<div class="panel-body">
<span class="pull-right">
<i class="fa fa-trash-o fa-lg" aria-hidden="true"></i>
<%= link_to "Remove", delete_image_attachment_tool_path(image), method: :delete, data: {confirm: "Are you sure?"} %>
</span>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
so I copied
<%= link_to image_tag(image, class:"img-thumbnail tools-gallery"), image %>
this to new listing pages stuff
so I modify the listing page
<% #tools.each do |tool| %>
<div class="row">
<div class="col-md-2">
<%= tool.images %>
<%= link_to image_tag(tool.images, class:"thumbnail"), images %>
</div>
<div class="col-md-7">
<h4><%= tool.listing_name %></h4>
</div>
<div class="col-md-3 right">
<%= link_to "Update", listing_tool_path(tool), class: "btn btn-black-free-account" %>
</div>
</div>
<hr/>
<% end %>
and all I got an error
even I have tried this
<%= link_to image_tag(tool, class:"thumbnail"), images %>
Tool.rb
class Tool < ApplicationRecord
belongs_to :user
has_many_attached :images
validates :tool_type, presence: true
validates :power_type, presence: true
validates :accessories, presence: true
validates :brand, presence: true
validates :price, presence: true
end
and I get same error, Any suggest would be great
In your model you have has_many_attached :images
tool.images regardless the number of images will alway return an ActiveSTorage::Attached::Many which is an Enumerable so you will have to loop through it to get each image, in the loop each image will be an ActiveStorage::Blob, to use image_tag you will need a url for the image, to get the url from the blob you would use url_for(image).
Here is an example:
<% tool.images.each do |image| %>
<%= image_tag(url_for(image), class: 'some-class') %>
<% end %>
In your case you wanted the image to be a link, that is easy to do as well you just have to pass the correct information to link_to. You can do this in multiple ways this is the way I think is the easiest to read.
With a link:
<% tool.images.each do |image| %>
<%= link_to "Path to Tool as string" do %>
<%= image_tag(url_for(image), class: 'some-class') %>
<% end %>
<% end %>
This is the API for link_to:
link_to name, options = {}, html_options = nil
This is the API for image_tag:
image_tag source, options={}
Lastly, you're seeing this error:
Can't resolve image into URL: undefined `to_model` for #<ActiveStorage::Attached::Many>
You are getting this error because you're try to create an image tag with a single image not a collection of "many".
Look at your original working code (superfluous HTML stripped away):
<% #tool.images.each do |image| %>
<%= link_to image_tag(image, class:"img-thumbnail tools-gallery"), image %>
<% end %>
Notice how you are looping through all the images? That is because a #tool has many images. It is an array of images. Inside the link_to block, you're defining an image_tag properly with a single image as the reference. Now lets look at your erroneous code:
<% #tools.each do |tool| %>
<%= tool.images %>
<%= image_tag(tool.images, class:"thumbnail"), images %>
<% end %>
This is weird. You're calling this:
<%= tool.images %>
Which just displays an instance of #<ActiveStorage::Attached::Many> and you're calling this:
<%= link_to image_tag(tool.images, class:"thumbnail"), images %>
Which just attempts (and fails) to link an array of images to a single image_tag instance which we know is invalid thanks to the api. You likely want to do this:
<% #tools.each do |tool| %>
<%= tool.images.each |image| %>
<%= image_tag(image, class:"thumbnail"), image %>
<% end %>
<% end %>
I am fairly new to Ruby on Rails, and I am trying to implement an advanced search. The advanced search is to search for books and their categories.
Please let me know if you need additional information.
I have implemented the advanced search form view, new view and show view.
But when I try to search for books, it doesn't display the search results neither doesn't render the show view for searches. It rather renders a new view page for Advanced Search.
Here is my Searches Controller Code
class SearchesController < ApplicationController
def new
#search = Search.new
end
def create
#search = Search.create(search_params)
redirect_to #search
end
def show
#search = Search.find(params[:id])
end
private
def search_params
params.require(:search).permit(:keywords, :category)
end
end
Here is my Search Model Code
class Search < ApplicationRecord
def search_books
books = Book.all
books = books.where(["name LIKE ?","%#{keywords}%"]) if
keywords.present?
books = books.where(["category LIKE ?",category]) if
category.present?
return books
end
end
Here is my Searches _form.html.erb Code
<%= form_with(model: search, local: true) do |form| %>
<div class="form-group">
<%= form.text_field :keywords, {placeholder: 'Keywords',
:class => 'form-control pb_height-50 reverse'} %>
</div>
<div class="form-group">
<%= form.text_field :category, {placeholder: 'Category',
:class => 'form-control pb_height-50 reverse'} %>
</div>
<div class="form-group">
<%= form.submit :class => 'btn btn-primary btn-lg btn-block
pb_btn-pill btn-shadow-blue', value: 'Search'%>
</div>
<% end %>
Here is my Searches new.html.erb Code
<% content_for :title, "New Search" %>
<section class="pb_cover_v3 overflow-hidden cover-bg-indigo cover-
bg-opacity text-left pb_gradient_v1 pb_slant-light menu-section"
id="section-home">
</section>
<section class="pb_section bg-light pb_slant-white pb_pb-250"
id="section-features">
<div class="container">
<div class="row align-items-center justify-content-center">
<div class="col-md-12 relative align-self-center">
<form action="/search" class="bg-white rounded pb_form_v1">
<h2 class="mb-4 mt-0 text-center">Advanced Search</h2>
<hr>
<%= render 'form', search: #search %>
<hr>
<%= link_to 'Back', books_path %>
</form>
</div>
</div>
</div>
</section>
Here is my Searches show.html.erb Code
<% content_for :title, "Search Result" %>
<section class="pb_cover_v3 overflow-hidden cover-bg-indigo
cover-bg-opacity text-left pb_gradient_v1 pb_slant-light menu-
section" id="section-home">
</section>
<section class="pb_section pb_slant-white pb_pb-250" id="section-
features">
<div class="container">
<div class="row titlerow">
<h1><%= Search Result %></h1>
<p><%= link_to 'Back', new_search_path %></p>
<% if #search.search_books.empty? %>
<p>No Records Found</p>
<% else%>
<% #search.search_books.each do |c| %>
<br>
<div class="div">
<h1><%= c.name %></h1>
<p>Category: <%=c.category %></p>
</div>
<% end %>
<% end %>
</div>
</div>
</section>
I need some assistance on how my search results can be displayed on the show view of the searches, instead of the Advanced Search page re-rendering the a new search page each time I click the Search Button of the Advanced Search. I need a way to connect the Show View of the Advanced Search to the New Advanced Search Page, so that it can display search results.
Thank you.
I was able to fix it.
On the new.html.erb
<section class="pb_section bg-light pb_slant-white pb_pb-250" id="section-features">
<div class="container">
<div class="row align-items-center justify-content-center">
<div class="col-md-12 relative align-self-center">
<form action="/search" class="bg-white rounded pb_form_v1">
<h2 class="mb-4 mt-0 text-center">Advanced Search</h2>
<hr>
<%= render 'form', search: #search %>
<hr>
<%= link_to 'Back', books_path %>
</form>
</div>
</div>
</div>
</section>
I simply changed the form tag to to a div tag, and also removed the action attribute from the form tag.
I have learnt a lot in the process.
That's all.
I hope this helps
I have a form on a page that is building a “tip” for a “guide”. Below the form, I am running an each loop over all the #guide.tips. I keep getting an error as the each loop is loading the forms blank object as it sees it as a tip. I’ve currently solved the problem by using jQuery to inject the form after page load, but there has to be a better solution.
Each Loop on Guide.html.erb
<% if !#guide.tips.blank? %>
<% #guide.tips.each do |tip| %>
<div class="row mx-1">
<div class="col-md-3 border-right">
<div class="float-left">
<%= image_tag avatar_url(tip.user), class: "float-left text-left align-middle rounded img-fluid mx-3", width: "30%" %>
<p><%= tip.user.fullname %></p>
</div>
<div class="float-right mr-3">
<%= link_to like_tip_path(tip), method: :put do %>
<div class="fas fa-angle-up"></div>
<%= tip.get_upvotes.size %>
<% end %><br/>
<%= link_to dislike_tip_path(tip), method: :put do %>
<div class="fas fa-angle-down"></div>
<%= tip.get_downvotes.size %>
<% end %>
</div>
</div>
<div class="col-md-8 ml-3">
<h6><%= tip.title %> -<span class="ml-1"><small><%= tip.created_at.strftime("%A, %d %b %Y %l:%M %p")%></small></span></h6>
<%= tip.tip %>
</div>
</div><hr/>
<% end %>
<% end %>
Tips_Controller.rb
def new
#guide = Guide.find(params[:guide_id])
#tip = Tip.new
end
def edit
end
def create
#guide = Guide.find(params[:guide_id])
params[:tip][:user_id] = current_user.id
#tip = #guide.tips.create!(tip_params)
redirect_to guide_path(#guide)
end
Tip Form Partial
<%= form_for([#guide, #guide.tips.build]) do |f| %>
<div class="form-group row">
<div class="col-sm-12">
<p class="text-left">Tip Title</p>
<%= f.text_field :title, placeholder: "Enter Title", class: "form-control" %>
</div>
<div class="col-sm-12 mt-2">
<p class="text-left">Your Tip</p>
<%= f.text_area :tip, placeholder:"What's your tip for this travel guide?", class: 'form-control' %>
</div>
</div>
<div class="form-group row">
<div class="col-md">
<%= f.submit 'Submit', class: 'btn btn-primary btn-block' %>
</div>
</div>
<% end %>
Here is another solution that does not separate the logic between the controller and the view and cleans up your empty array statement for your loop
Each Loop on Guide.html.erb
<% #guide.tips.each do |tip| %>
<div class="row mx-1">
<div class="col-md-3 border-right">
<div class="float-left">
<%= image_tag avatar_url(tip.user), class: "float-left text-left align-middle rounded img-fluid mx-3", width: "30%" %>
<p><%= tip.user.fullname %></p>
</div>
<div class="float-right mr-3">
<%= link_to like_tip_path(tip), method: :put do %>
<div class="fas fa-angle-up"></div>
<%= tip.get_upvotes.size %>
<% end %><br/>
<%= link_to dislike_tip_path(tip), method: :put do %>
<div class="fas fa-angle-down"></div>
<%= tip.get_downvotes.size %>
<% end %>
</div>
</div>
<div class="col-md-8 ml-3">
<h6><%= tip.title %> -<span class="ml-1"><small><%= tip.created_at.strftime("%A, %d %b %Y %l:%M %p")%></small></span></h6>
<%= tip.tip %>
</div>
</div><hr/>
<% end unless #guide.tips.blank? %>
Tip Form Partial
By creating the Tip from outside the association (i.e. not using build), it will not be loaded into the class variable's children
<%= form_for([#guide, Tip.new(guide: #guide)]) do |f| %>
<div class="form-group row">
<div class="col-sm-12">
<p class="text-left">Tip Title</p>
<%= f.text_field :title, placeholder: "Enter Title", class: "form-control" %>
</div>
<div class="col-sm-12 mt-2">
<p class="text-left">Your Tip</p>
<%= f.text_area :tip, placeholder:"What's your tip for this travel guide?", class: 'form-control' %>
</div>
</div>
<div class="form-group row">
<div class="col-md">
<%= f.submit 'Submit', class: 'btn btn-primary btn-block' %>
</div>
</div>
<% end %>
Another Example / Q&A
Using the structure you already have you could do:
<% if #guide.tips.count > 1 %> (assuming this will always be shown with an empty "build" tip)
or you can use:
<% next unless tip.persisted? %>
inside the loop, before the actual form.
You also don't need the blank? check as an .each on an empty enumerator simply won't execute the block, and as long as there's a has_many relationship between guide and tips it will always yield a collection proxy.
I would write it as:
<% #guide.tips.each do |tip| %>
<% next unless tip.persisted? %>
<div class="row mx-1">
<div class="col-md-3 border-right">
...
<% end %>
I'm attempting to create a "Save Changes" button for a form that would send data via ajax to the update method in the controller. The aim is to allow form users to save their work without the form reloading or redirecting. However I'm running into a bit of a problem; I'm getting the following error
undefined method `update_incorporation_path'
To be clear, incorporation is the controller that we're working with. Below is the code I added to accomplish this.
To my view, I added:
<%= button_to "", update_incorporation_path(#incorporation), :remote => true, :method => :post %>
To my routes, I added:
resources :incorporations do
member do
post 'update'
end
end
The update method looks like this:
def update
if #incorporation.update(incorporation_params)
if admin_signed_in?
#incorporations = Incorporation.all.order("created_at DESC")
else
#incorporations = current_user.incorporations("created_at DESC")
end
render action: "index"
else
render 'edit'
end
end
The complete view is below:
edit.html.erb
<%= render 'form' %>
<br/>
<%= link_to "Back", root_path, class: "btn btn-default" %>
_form.html.erb (the buttons are at the bottom)
<div id="wrapper" class="active main-content">
<%= simple_form_for #incorporation do |f| %>
<!-- Sidebar -->
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul id="sidebar_menu" class="sidebar-nav">
<li class="sidebar-brand"><a id="menu-toggle" href="#">Menu<span id="main_icon" class="glyphicon glyphicon-align-justify"></span></a></li>
</ul>
<% #sections=[["basic_info", "Basic Info"],["address", "Address"],["equity", "Equity"],["officers","Officers"],["directors", "Directors"],["contractor","Contractors"],["ip","IP"],["shareholders", "Shareholders"]] %>
<ul class="sidebar-nav" id="sidebar">
<% #sections.each do |section| %>
<li><span class="sub_icon glyphicon glyphicon-link"></span><%= section[1] %></li>
<% end %>
</ul>
<div id="save">Save</div>
</div>
<div class="panel-body">
<div id="basic_info" class="form_section">
<div class="form-left"><h2>Basic Info</h2></div>
<div class="form-right">
<%= f.simple_fields_for :company do |company| %>
<div class="padded-fields">
<%= render 'basic_fields', company:company %>
</div>
<% end =%>
<div class="padded-fields">
<div class="form_subsection">
<%= f.input :trademark_search, as: :radio_buttons, label: 'Would you like us to do a trademark search and provide advice regarding any issues we identify in relation to the name you have selected?', input_html: { class: 'form-control' } %>
</div>
</div>
</div>
</div>
<%= f.simple_fields_for :company do |company| %>
<div id="address" class="form_section">
<%= render 'address_fields' , company:company %>
</div>
<div id="equity" class="form_section">
<%= render 'equity_fields' , company:company %>
</div>
<div id="officers" class="form_section">
<div class="form-left"><h2>Officers</h2><br/><p>Please list the officers of the company.</p></div>
<div class="form-right">
<div>
<%= company.simple_fields_for :officers do |officer|%>
<%= render 'officer_fields', f: officer %>
<% end =%>
<%= link_to_add_association 'Add Officer', company, :officers, class: "btn btn-default add-button" %>
</div>
</div>
</div>
<div id="directors" class="form_section">
<div class="form-left"><h2>Directors</h2><br/><p>Please list the initial directors of the company. We recommend an odd number to avoid a deadlocked board.</p></div>
<div class="form-right">
<div>
<%= company.simple_fields_for :people do |person|%>
<%= render 'person_fields', f: person %>
<% end =%>
<%= link_to_add_association 'Add Director', company, :people, class: "btn btn-default add-button" %>
</div>
</div>
</div>
<div id="contractor" class="form_section">
<div class="form-left"><h2>Employees Contractors</h2></br><p>Please list all employees, independent contractors and any other individual or entity who will be providing services to the company at the time of incorporation. Each of these persons should have written agreements with the company. Please check the box next to each name for whom you would like us to prepare agreements</p></div>
<div class="form-right">
<div>
<%= company.simple_fields_for :contractor_people do |contractor| %>
<%= render 'contractor_person_fields', f:contractor %>
<% end =%>
<%= link_to_add_association 'Add Person', company, :contractor_people, class: "btn btn-default add-button" %>
</div>
<div class="form_subsection">
<div>
<%= company.simple_fields_for :contractor_orgs do |contractor| %>
<%= render 'contractor_org_fields', f:contractor %>
<% end =%>
<%= link_to_add_association 'Add Company', company, :contractor_orgs, class: "btn btn-default add-button" %>
</div>
</div>
</div>
</div>
<div id="ip" class="form_section">
<div class="form-left">
<h2>Intellectual Property</h2><br/><p>Please list existing intellectual property (including business plans, software, artwork, inventions, trade secrets and the like) that has been created for use in the company and the name of the person or people who created it.</p>
</div>
<div class="form-right">
<div>
<%= company.simple_fields_for :ips do |ip| %>
<%= render 'ip_fields', f: ip %>
<% end =%>
<div class="add-field"><%= link_to_add_association 'Add IP', company, :ips, class: "btn btn-default add-button" %></div>
</div>
</div>
</div>
<div id="shareholders" class="form_section">
<div class="form-left"><h2>Shareholders</h2><br/><p>Please list all individuals to hold equity in this company.</p></div>
<div class="form-right">
<div>
<%= company.simple_fields_for :shareholders do |shareholder|%>
<%= render 'shareholder_fields', f: shareholder %>
<% end =%>
<%= link_to_add_association 'Add Shareholder', company, :shareholders, class: "btn btn-default add-button" %>
</div>
</div>
</div>
<% end =%>
</div>
<%= f.button :submit, id:"incorporation_submit", class: "btn btn-primary" %>
<%= button_to "Update", incorporation_path(#incorporation), method: :post, remote: true %>
<% end =%>
</div>
I figure I must be forgetting something. Any thoughts are much appreciated.
Routes for update method was by default added when you wrote resources :incorporations, so change your routes to
resources :incorporations
And your path should be incorporation_path, also method in button_to is by default post, you don't need to write it,
change your button_to to
<%= button_to "Update", incorporation_path(#incorporation), :remote => true %>
But, if you are submitting a form, it should have a submit button instead of button_to, your form should look like this
<%= form_for #incorporation, remote: true do |f| %>
# form content
<%= f.submit "Submit" %>
<% end %>
Hope this helps!
Instead of :
<%= button_to "", update_incorporation_path(#incorporation),
:remote => true, :method => :post %>
Try :
<%= button_to "Update", incorporation_path(#incorporation),
method: :post, remote: true %>
In your route:
resources :incorporations
The resources ships with default actions index,new, create,edit, update, destroy. You don't need to declare it manually.
You can verify the routes from your console.
rake routes | grep 'incorporations'
You will get output like :
From here you can construct your path for the update action.
Hope it helps :)
i have this form :
<h1> Global data management </h1> </br> </br>
<h2>Enter the conditions and click "find" option to search for users based on conditions. </br> Or click the "List" option to list all the data. </h2>
</br></br></br>
<%= form_for(:find_field, url: find_field_path , method: :get) do |f| %>
<div class="row">
<div class="span8 offset1">
<div class = "row">
<div class = "span4">
<div class="field">
<%= f.label :data_type_choice, "Data type" %>
<%= f.select :data_type_choice, [["all","all"],["2D","2D"],["3D","3D"],["2D3C","2D3C"],["3D3C","3D3C"]] , :name => nil%>
</div>
</br></br>
<h3> COMPLETED WITHIN </h3>:</br>
<div class="field">
<%= f.label :from_date_choice , "From date " %>
<%= f.date_select :from_date_choice , :name => nil%>
</div>
</div>
<div class = "span4">
<div class="field">
<%= f.label :basin_choice, "Basin" %>
<%= f.select :basin_choice, [["all","all"],["Cauvery","Cauvery"],["KG-PG","KG-PG"],["others","others"]] , :name => nil %>
</div>
</br></br>
<h3> </h3>
<div class="field">
<%= f.label :to_date_choice , "To date " %>
<%= f.date_select :to_date_choice , :name => nil %>
</div>
</div>
</div>
</br></br>
<%= f.submit " Search ", class: "btn btn-large btn-primary" %>
</div>
</div>
<% end %>
everything works perfectly, all the parameters are passed correctly etc, but in the view where im trying to display the result, i get a HUGE url like so:
http://localhost:3000/global/data/find?utf8=%E2%9C%93&find_field%5Bdata_type_choice%5D=2D&find_field%5Bfrom_date_choice%281i%29%5D=2012&find_field%5Bfrom_date_choice%282i%29%5D=7&find_field%5Bfrom_date_choice%283i%29%5D=9&find_field%5Bbasin_choice%5D=KG-PG&find_field%5Bto_date_choice%281i%29%5D=2012&find_field%5Bto_date_choice%282i%29%5D=7&find_field%5Bto_date_choice%283i%29%5D=9&commit=++Search++
ive tried using the ":name => nil" as shown in this railscast
why is this happening and how can i reduce the url size to just "http://localhost:3000/global/data/find" ?
EDIT:
this is my find method in fields_controller:
def find
#data_type_choice = params[:find_field][:data_type_choice]
#basin_choice = params[:find_field][:basin_choice]
#from_date_choice = params[:find_field][:from_date_choice]
#to_date_choice = params[:find_field][:to_date_choice]
end
i also want to display the data entered in the form through find.html.erb like so:
<h1><%= #data_type_choice %> dsfgdfsg</h1>
if i make it a post request, the erb is not being rendered! what can i do?
thanks :)
Just change your method from GET to POST and change the routes accordingly.
Try
<%= form_for(:find_field, url: find_field_path , method: :post) do |f| %>
Your routing file should match the request as POST.