I am new to Spree. I want to deface link_to rails helper.
i have spree/checkout/_new_user file and it contain following:
<%= link_to Spree.t(:login_as_existing), spree.login_path %>
i want to add remote: true to above link_to using deface.
Please Help.
You can replace links
Deface::Override.new(virtual_path: 'checkout/_new_user',
name: 'add remote true to link",
replace: "erb[loud]:contains('link_to Spree.t(:login_as_existing), spree.login_path'),
text: "<%= link_to Spree.t(:login_as_existing), spree.login_path, remote: true %>")
Related
In My Rails 5 Web App. I have installed Devise gem in it. When I wan to edit my password by clicking on link below but instead on going to the page for update password. Page get refreshed and It gives alert message you are already logged in .
I am using Below link in my Application:
<%= link_to('Edit Password' , edit_user_password_path)%>
Routes Files is as:
devise_for :users, controllers: { sessions: "users/sessions" }
Please suggest me the changes to redirect to edit password page all other links like below are working.
<%= link_to('Edit Registration',edit_user_registration_path )%>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
<%= link_to('Edit Registration', edit_user_registration_path) %>
<%= link_to('Edit Password', edit_user_password_path) %>
I'm trying to customize my dialog confirm the link_to in rails 4. But I do not understand why he rides the html as "confirm", and should be "data-confirm"!
I've tried a number of ways, and it is always generated "confirm", like this:
<%= link_to 'Delete', user, :method => :delete, :confirm => 'Are you sure?' %>
<a confirm="Are you sure?" rel="nofollow" data-method="delete" href="/user/13">Delete</a>
I followed this tutorial:
http://thelazylog.com/custom-dialog-for-data-confirm-in-rails/
and i used the example in tutorial, but also doesn't work
Confirm has been deprecated in rails 4.
So use new syntax:
<%= link_to "title", "#", data: {confirm: "Are you sure!"} %>
To get the same behavior in rails 7 you should use turbo_confirm key instead:
<%= link_to 'Delete', user,
data: {turbo_method: :delete, turbo_confirm: 'Are you sure?'} %>
When I am searching for gender field say "male", it searches for "male" and "female" as "male" keywork is in "female" too.
So How can I use ransack in rails so that it matches for exact keyword instead of any partial group of chars.
PS:similarly how can I enable or disable the exact or partial key match in RANSACK gem.
I believe you could just do
<%= search_form_for #q do |f| %>
<%= f.label :gender_eq, "Gender:" %>
<%= f.search_field :gender_eq %>
<% end %>
that will tell the search to look for the exact string of your input
Here is some of the info from the developer on how it's used.
https://github.com/activerecord-hackery/ransack#in-your-view
I believe the way you do your search is <%= (field_name)_cont ... %> cont means contains.
What you want is _eq, change your view into <%= (field_name)_eq ... %> and it should work.
For more info:
https://github.com/activerecord-hackery/ransack/wiki/Basic-Searching
I am a beginner to Rails. Was working along with Railsguide for Rails 4.
One confusion i have is:
for adding a link , somewhere it is written like:
<h1>Hello, Rails!</h1>
<%= link_to "My Blog", controller: "posts" %>
whereas somewhere its like
<%= link_to 'New post', new_post_path %>
Please clarify the difference.
Good question. Both of these are link helpers, and both are resource-oriented (check out the Rails UrlHelper docs for more information).
The first one will render a link that is associated with the particular controller:
<%= link_to "My Blog", controller: "posts" %>
<a href='/posts'>
The second will render the Rails path specific to creating a new Post object (this is also resource-oriented). Check out section 2.3 in the Rails routing guide:
<%= link_to 'New post', new_post_path %>
<a href='/posts/new'>
Ruby 2.1
Rails 4.1
It should be pretty simple to upload a file without using any gems. I would include in a form something like this:
<% form_for #upload, :multipart => true do |f| %>
<%= f.file_field :uploaded_file %>
<%= f.submit "Upload file" %>
<% end %>
What I want to do is upload the file through a single menu action. How do I go about doing this?