To get the file extension excluding the "." then do the following
@file_extension = file_name.split('.').pop()
To get the file extension along with "." then do the following
@file_extension = file_name.scan(/\.\w+$/)
Using Jquery
var ext = $('#file_field_id').val().split('.').pop().toLowerCase();
Monday, May 31, 2010
Thursday, May 27, 2010
Access to /etc/hosts denied while modifying host file
This problem occurs when you do not have the administrative rights.
You get an error when you try to edit the LMHOSTS or HOSTS file under Windows Vista.
Access to C:\WindowsSystem32\drivers\etc\ hosts was denied
or
Cannot create the C:\Windows\System32\drivers\etc\hosts file.
Make sure that the path and file name are correct.
To solve this problem:
1. Click Start–>All Programs–>Accessories–>Notepad–>Run as administrator.
If you are prompted for an administrator password or for a confirmation, type the password, or click Allow.
2. Open the Hosts file or the Lmhosts file, make the necessary changes, and then click Save on the Edit menu.
You get an error when you try to edit the LMHOSTS or HOSTS file under Windows Vista.
Access to C:\WindowsSystem32\drivers\etc\ hosts was denied
or
Cannot create the C:\Windows\System32\drivers\etc\hosts file.
Make sure that the path and file name are correct.
To solve this problem:
1. Click Start–>All Programs–>Accessories–>Notepad–>Run as administrator.
If you are prompted for an administrator password or for a confirmation, type the password, or click Allow.
2. Open the Hosts file or the Lmhosts file, make the necessary changes, and then click Save on the Edit menu.
Friday, May 21, 2010
How to make dynamic on focus popup in the grid.
If you have a data table and need to display a on focus popup which shows the related columns content then you can do the following:
<% @objects.each do |object| %>
<%=h object.name%>
Show
<%if object.regions.nil?%>
<% end %>
<% end %>
<% @objects.each do |object| %>
<%=h object.name%>
Show
No regions selected | ||
---|---|---|
State | Super Region | Region |
<%= state_name %> | <%if region.super_region.nil? super_region_name = "" else super_region_name = region.super_region.super_region_description end%><%= super_region_name %> | <%if region.region.nil? region_name = "" else region_name = region.region.region_description end%><%= region_name %> |
<% end %>
<% end %>
Subscribe to:
Posts (Atom)